#[non_exhaustive]pub enum Error {
Show 20 variants
Io(Error),
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),
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.
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.
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()