#[non_exhaustive]pub enum Error {
Show 33 variants
Io(Error),
BadPageSize(Size),
TooManyGlyphs,
VariableFontsDisabled,
ForeignGlyphFont,
PngNeedsDecoding,
BlankDocument(String),
EncryptedSaveUnsupported,
PasswordNotText,
NoEntropy,
NoDestinationCatalog,
PageIndexOutOfRange(PageIndex),
BadPageRange,
BadNupParams,
Svg(Error),
Subset(String),
UnrecognisedFontProgram,
EmptyFontProgram,
EmptyToUnicodeCMap,
BadCidToGidMap(usize),
UnrecognisedImageData,
EmptyImage,
ImageDataLength {
expected: usize,
found: usize,
},
MissingGlyph(MissingGlyph),
InlinePage(PageIndex),
EmptyQuadPoints,
AnnotNotOnPage(ObjRef, PageIndex),
AnnotIndexOutOfRange(usize, PageIndex),
DuplicateFieldName(String),
EmptyFieldName,
EmptyRadioGroup,
DuplicateAttachmentName(String),
Object(Error),
}Expand description
A failure that stops the editor producing output.
Damage in the input is not an error here: a broken object silently
vanishes from the output the way the C++ writer drops it, and every such
recovery is recorded as a pdfrum_common::Diagnostic. Err is reserved
for “cannot continue”.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io(Error)
The sink refused the bytes.
BadPageSize(Size)
A page size for blank_document that is not
finite and positive.
TooManyGlyphs
A glyph font drew more than 65 535 distinct glyphs, all an Identity-H code can name.
VariableFontsDisabled
A glyph font needs instancing — a CFF2 face, or a variable instance
other than the default — and the variable-fonts feature is off.
ForeignGlyphFont
A glyph run named a GlyphFont this session did not
embed.
PngNeedsDecoding
A PNG EditDoc::embed_png cannot pass
through as stored: alpha, tRNS, interlacing or 16-bit samples.
BlankDocument(String)
The blank document did not read back. Not expected: the bytes are this crate’s own; the message is the parser’s.
EncryptedSaveUnsupported
The document declares /Encrypt, this reader derived no key for it
(an /Identity crypt filter, or a handler opened as
pdfrum_crypt::SecurityHandler::Identity), and remove_security
was not set. Re-declaring a cipher over plaintext would produce a file
nothing could open.
PasswordNotText
A password given for a new encryption is not valid UTF-8, or does
not survive SASLprep (ISO 32000-2 §7.6.4.3.3).
NoEntropy
The operating system’s cryptographic generator is unavailable, so the file key and AES vectors a new encryption needs cannot be drawn. Only an encrypting save can raise this; every other save needs no randomness it cannot derive.
NoDestinationCatalog
A document with no usable catalog cannot be the destination of an import: there is nowhere to attach the pages.
PageIndexOutOfRange(PageIndex)
A page index named by an import is outside the source document.
BadPageRange
A page-range string the grammar of ISO 32000 viewers accepts could not be parsed; the C++ treats one bad entry as discarding everything.
BadNupParams
N-up was asked for a grid or sheet size with a zero dimension.
Svg(Error)
svg-import only.An SVG would not resolve. Only produced with the svg-import
feature, whose ingestion parses it.
Subset(String)
The font program could not be subset.
UnrecognisedFontProgram
The bytes are not a TrueType, OpenType, or Type 1 font program.
EmptyFontProgram
The program parsed but declares no glyphs.
EmptyToUnicodeCMap
A caller-supplied /ToUnicode CMap was empty.
The font it would write would carry no statement of what its codes
mean. A caller who wanted a generated /ToUnicode should ask for
FontEncoding::Composite instead.
BadCidToGidMap(usize)
A caller-supplied /CIDToGIDMap was empty, or was not a whole number
of big-endian u16 entries.
[oracle-bug] ISO 32000-1 §9.7.4.2 defines /CIDToGIDMap as a stream
of two-byte glyph indices, so a half-entry is not a map. Both the
empty and the odd-length case are rejected here, before any of it is
written.
UnrecognisedImageData
The bytes are not a JPEG or JPEG 2000 codestream a PDF may hold.
Raised when no JPEG header can be read, when the component count is not 1, 3 or 4, or when the sample precision is not 1, 2, 4, 8 or 16. The oracle reaches the same outcome by producing no stream at all; this is the same refusal with the reason attached.
EmptyImage
An image was asked for with a zero width or height.
ImageDataLength
The sample buffer is not the length the dimensions and pixel format require.
The oracle cannot reach this: its API takes a bitmap object that already knows its own pitch, so a short buffer is not expressible. Loose bytes are, and reading past them is not an option.
Fields
MissingGlyph(MissingGlyph)
A drawing refused a character the font has no glyph for.
Raised by EmbeddedFont::encode_checked
and by the facade’s canvas, which encodes through it. A blank where a
glyph should be is a worse answer than a refusal, because nothing
downstream can tell the two apart.
InlinePage(PageIndex)
A page written inline in its parent’s /Kids has no object of its own
for an appended content stream to reach.
EmptyQuadPoints
A highlight or underline was asked for with no /QuadPoints.
ISO 32000-1 §12.5.6.10 requires the array; an empty one is not a markup of anything.
AnnotNotOnPage(ObjRef, PageIndex)
update_annotation / delete_annotation named an object that is not
listed in that page’s /Annots.
AnnotIndexOutOfRange(usize, PageIndex)
update_annotation_at / delete_annotation_at named an index outside
the page’s /Annots array (or the page has no /Annots).
DuplicateFieldName(String)
add_form_field was given a name the document already uses.
A field’s fully qualified name is its identity, not a label: the reader merges two fields sharing one into a single field with two controls, and every lookup, action and script then addresses both at once. So a collision is refused rather than written.
EmptyFieldName
add_form_field was given an empty name.
The reader drops a field with no name anywhere in its ancestry, so such a field would be written and then silently lost on the next load.
EmptyRadioGroup
add_form_field was given a radio group with no buttons.
DuplicateAttachmentName(String)
set_attachment_name was given a name another attachment already has.
The embedded-files tree is keyed by name, so writing a duplicate would leave one of the two unreachable by the only lookup there is.
Object(Error)
An object the writer needed could not be fetched or made sense of.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<MissingGlyph> for Error
impl From<MissingGlyph> for Error
Source§fn from(source: MissingGlyph) -> Self
fn from(source: MissingGlyph) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.