#[non_exhaustive]pub struct Policy {
pub unembeddable_font: Concession,
pub unrepresentable_content: Concession,
pub forbidden_feature: Concession,
}Expand description
What the conversion is permitted to do to a document it cannot convert faithfully.
Every field defaults to Concession::Refuse, so Policy::default() is
the strict policy: convert what can be converted losslessly and refuse
anything else. Widening it is an explicit act per axis.
The axes are separate because a caller’s answers genuinely differ between them — an archive may accept a substituted font (the text stays text, and stays searchable) while refusing a rasterized page (the text stops being text at all).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.unembeddable_font: ConcessionA font that is used for rendering, is not embedded, and whose program we do not have.
Refusing stops the conversion and names the font, because an unembedded font is a hard PDF/A failure that no amount of other repair will fix.
Accepting is meant to substitute a standard font of the same broad
shape. That repair is not implemented yet, so
today accepting means “convert as far as you can”: every other repair
applies, the font stays unembedded, and no Compromise is reported
because nothing was compromised. It is the honest reading of Accept
until the substitution lands.
unrepresentable_content: ConcessionContent the level forbids outright and that cannot be rewritten — transparency under A-1b being the case.
Refusing stops the conversion and names the page. Only A-1b can reach this: A-2b permits transparency, so nothing there is unrepresentable.
Accepting is meant to rasterize the offending page — faithful to the
appearance, and destroying the text, the vectors and the
selectability. That repair is not implemented yet, so accepting reads as “convert as far as you can” exactly as
Policy::unembeddable_font does, and
Conversion::rasterized_pages is always empty for now.
forbidden_feature: ConcessionAn annotation or action of a kind PDF/A forbids.
Accepting removes it — the JavaScript, the /Launch action, the
/Movie annotation. Refusing stops the conversion. This is separated
from the two above because it is the one most callers do want: a
launch action in an archived file is a liability, not content, and
stripping it is the point of archiving rather than a loss.
It also covers one repair that adds rather than removes: PDF/A
requires every annotation be visible and printable, so an annotation
hidden by its /F flags has them cleared and becomes visible. That
changes what the page draws, which is why it needs permission and
reports Compromise::AnnotationFlagsChanged.
Implementations§
Source§impl Policy
impl Policy
Sourcepub const fn strict() -> Self
pub const fn strict() -> Self
Refuse every compromise: convert only what converts losslessly.
The same as Policy::default(), named so a caller can say what they
mean at the call site.
Sourcepub const fn lossy() -> Self
pub const fn lossy() -> Self
Accept every compromise the pipeline knows how to make.
The archivist’s policy: produce a conforming file and tell me what it
cost. Every compromise still lands in Conversion::compromises — the
difference from Policy::strict is what stops the conversion, never
what goes unreported.
Sourcepub const fn unembeddable_font(self, concession: Concession) -> Self
pub const fn unembeddable_font(self, concession: Concession) -> Self
This policy with Policy::unembeddable_font set.
The struct is #[non_exhaustive] so that a concession added later is
not a breaking change for callers — which also means a caller cannot
write a struct literal. These three are how a policy is built from one
of the two named starting points:
use pdfrum_doc::pdfa::{Concession, Policy};
// Strip what PDF/A forbids, but never substitute a font behind my back.
let policy = Policy::strict().forbidden_feature(Concession::Accept);
assert!(policy.forbidden_feature.accepts());
assert!(!policy.unembeddable_font.accepts());Sourcepub const fn unrepresentable_content(self, concession: Concession) -> Self
pub const fn unrepresentable_content(self, concession: Concession) -> Self
This policy with Policy::unrepresentable_content set.
Sourcepub const fn forbidden_feature(self, concession: Concession) -> Self
pub const fn forbidden_feature(self, concession: Concession) -> Self
This policy with Policy::forbidden_feature set.