#![allow(
clippy::too_many_lines,
clippy::match_same_arms,
clippy::doc_markdown,
reason = "generated: one match arm per code; summaries are codes.json text"
)]
use crate::ErrorKind;
pub const DOCS_URL_BASE: &str = "https://docs.laminapdf.com/reference/codes/";
pub const DOCS_URL_SUFFIX: &str = "/";
const fn bytes_eq(a: &[u8], b: &[u8]) -> bool {
if a.len() != b.len() {
return false;
}
let (mut a, mut b) = (a, b);
while let ([x, a_rest @ ..], [y, b_rest @ ..]) = (a, b) {
if *x != *y {
return false;
}
a = a_rest;
b = b_rest;
}
true
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ErrorCode {
NotPdf,
MissingRoot,
ReferenceCycle,
LimitExceeded,
Strict,
DataPending,
Source,
Type,
InvalidStructure,
UnsetObject,
RepairedBase,
EncryptedBase,
PasswordRequired,
WrongPassword,
UnsupportedSecurityHandler,
UnexpectedEof,
Syntax,
UnsupportedFilter,
Decompress,
NestedTransaction,
NoTransaction,
UnknownPage,
DirectPage,
UnsupportedVersion,
InvalidOpLog,
SavedNotRebased,
NoPendingSave,
MalformedXmp,
UnknownSource,
OpenActionNotDestination,
UnknownOutlineItem,
DirectOutlineItem,
OutlineNotASibling,
OutlineMoveIntoItself,
UnknownNamedDestination,
NamedDestinationExists,
EmptyDestinationName,
LinkUriRefused,
ViewNotFinite,
XmpClaimReadOnly,
InvalidXmpPacket,
InvalidXmpProperty,
NoPagesLeft,
InvalidOp,
UnknownAnnotation,
AnnotationLocked,
AnnotationNotEditable,
NotALink,
LinkNotTagged,
AppearanceUnavailable,
AppearanceNeedsText,
AnnotationGlyphMissing,
AnnotationFontInvalid,
StampImageInvalid,
InvalidLabelRanges,
ContentObjectStale,
ContentNotEditable,
UnknownBlob,
ImagesUnavailable,
FlattenWidget,
UnknownAttachment,
AttachmentTooLarge,
UnknownField,
FieldIsSignature,
SignFieldSigned,
SignCertifyNotFirst,
FieldValueInvalid,
FieldNameTaken,
FieldNameInvalid,
PdfaFieldActions,
TabOrderNeedsStructure,
TabOrderInvalid,
ContentIdInUse,
UnknownContentObject,
UnknownPageMark,
ContentObjectInvalid,
ContentNeedsAltText,
ContentGlyphMissing,
ContentFontInvalid,
ContentFontNotEmbeddable,
EncryptionNoPassword,
EncryptionPdfaConflict,
SecretMissing,
OwnerPasswordRequired,
NotEncrypted,
Sink,
NotRebased,
SinkNotEmpty,
WouldInvalidateSignatures,
RequiresRewrite,
EncryptionIncomplete,
EncryptionNoEntropy,
SignPlaceholderTooSmall,
SignKeyUnsupported,
SignSignerFailed,
SignDocumentChanged,
SignatureMalformed,
SignatureAlgorithmUnsupported,
InvalidFont,
CollectionIndex,
UnknownAxis,
FontNotEmbeddable,
MissingGlyph,
GlyphOutOfRange,
UnknownFont,
SubsetFailed,
InvalidAxisValue,
WrongDocument,
InvalidFeature,
InvalidTextRange,
InvalidSpans,
UnsupportedLayoutOption,
FontMismatch,
EncodingFull,
FontNotShapable,
InvalidImage,
UnsupportedImage,
ImageTooLarge,
ImageDataLength,
InvalidIccProfile,
ColorComponents,
InvalidColor,
InvalidGeometry,
TextOverflow,
PageIndexOutOfRange,
UnknownDestination,
InvalidPageLabels,
TagElementNotOpen,
TagElementUnclosed,
ProfileVersionConflict,
MissingTitle,
MissingLang,
MissingAltText,
UntaggedContent,
HeadingLevelSkipped,
UnnumberedHeadingMisused,
InvalidStructureNesting,
LinkWithoutStructure,
LinkWithoutContents,
FontNotEmbedded,
GlyphWithoutUnicode,
DeviceColorWithoutOutputIntent,
EmbeddedFileForbidden,
EmbeddedFileWithoutMimeType,
FlowContentTooLarge,
FlowLayoutUnstable,
InvalidDocument,
TemplateDataMissing,
TemplateDataType,
TemplateTooLarge,
RenderTooLarge,
RenderFailed,
RenderBackendUnavailable,
ExportFailed,
ModelFailed,
ModelResultUnexpected,
ModelNeedsHost,
InterchangeUnknownFormat,
InterchangeMalformed,
InterchangeDtd,
SubmitPdfRefused,
SubmitUrlRefused,
InterchangeTooLarge,
Cancelled,
JobFinished,
DocumentChanged,
RevisionIndexOutOfRange,
NoBookmarks,
SoundUnavailable,
BuilderFinished,
Disposed,
InvalidArgument,
SourceBudgetExceeded,
UnknownOption,
InvalidCommandLine,
InvalidPageRange,
BinaryOutputToTerminal,
UnknownCode,
OverwriteRefused,
InputUnreadable,
OutputUnwritable,
PathOutsideRoots,
}
impl ErrorCode {
pub const ALL: &'static [Self] = &[
Self::NotPdf,
Self::MissingRoot,
Self::ReferenceCycle,
Self::LimitExceeded,
Self::Strict,
Self::DataPending,
Self::Source,
Self::Type,
Self::InvalidStructure,
Self::UnsetObject,
Self::RepairedBase,
Self::EncryptedBase,
Self::PasswordRequired,
Self::WrongPassword,
Self::UnsupportedSecurityHandler,
Self::UnexpectedEof,
Self::Syntax,
Self::UnsupportedFilter,
Self::Decompress,
Self::NestedTransaction,
Self::NoTransaction,
Self::UnknownPage,
Self::DirectPage,
Self::UnsupportedVersion,
Self::InvalidOpLog,
Self::SavedNotRebased,
Self::NoPendingSave,
Self::MalformedXmp,
Self::UnknownSource,
Self::OpenActionNotDestination,
Self::UnknownOutlineItem,
Self::DirectOutlineItem,
Self::OutlineNotASibling,
Self::OutlineMoveIntoItself,
Self::UnknownNamedDestination,
Self::NamedDestinationExists,
Self::EmptyDestinationName,
Self::LinkUriRefused,
Self::ViewNotFinite,
Self::XmpClaimReadOnly,
Self::InvalidXmpPacket,
Self::InvalidXmpProperty,
Self::NoPagesLeft,
Self::InvalidOp,
Self::UnknownAnnotation,
Self::AnnotationLocked,
Self::AnnotationNotEditable,
Self::NotALink,
Self::LinkNotTagged,
Self::AppearanceUnavailable,
Self::AppearanceNeedsText,
Self::AnnotationGlyphMissing,
Self::AnnotationFontInvalid,
Self::StampImageInvalid,
Self::InvalidLabelRanges,
Self::ContentObjectStale,
Self::ContentNotEditable,
Self::UnknownBlob,
Self::ImagesUnavailable,
Self::FlattenWidget,
Self::UnknownAttachment,
Self::AttachmentTooLarge,
Self::UnknownField,
Self::FieldIsSignature,
Self::SignFieldSigned,
Self::SignCertifyNotFirst,
Self::FieldValueInvalid,
Self::FieldNameTaken,
Self::FieldNameInvalid,
Self::PdfaFieldActions,
Self::TabOrderNeedsStructure,
Self::TabOrderInvalid,
Self::ContentIdInUse,
Self::UnknownContentObject,
Self::UnknownPageMark,
Self::ContentObjectInvalid,
Self::ContentNeedsAltText,
Self::ContentGlyphMissing,
Self::ContentFontInvalid,
Self::ContentFontNotEmbeddable,
Self::EncryptionNoPassword,
Self::EncryptionPdfaConflict,
Self::SecretMissing,
Self::OwnerPasswordRequired,
Self::NotEncrypted,
Self::Sink,
Self::NotRebased,
Self::SinkNotEmpty,
Self::WouldInvalidateSignatures,
Self::RequiresRewrite,
Self::EncryptionIncomplete,
Self::EncryptionNoEntropy,
Self::SignPlaceholderTooSmall,
Self::SignKeyUnsupported,
Self::SignSignerFailed,
Self::SignDocumentChanged,
Self::SignatureMalformed,
Self::SignatureAlgorithmUnsupported,
Self::InvalidFont,
Self::CollectionIndex,
Self::UnknownAxis,
Self::FontNotEmbeddable,
Self::MissingGlyph,
Self::GlyphOutOfRange,
Self::UnknownFont,
Self::SubsetFailed,
Self::InvalidAxisValue,
Self::WrongDocument,
Self::InvalidFeature,
Self::InvalidTextRange,
Self::InvalidSpans,
Self::UnsupportedLayoutOption,
Self::FontMismatch,
Self::EncodingFull,
Self::FontNotShapable,
Self::InvalidImage,
Self::UnsupportedImage,
Self::ImageTooLarge,
Self::ImageDataLength,
Self::InvalidIccProfile,
Self::ColorComponents,
Self::InvalidColor,
Self::InvalidGeometry,
Self::TextOverflow,
Self::PageIndexOutOfRange,
Self::UnknownDestination,
Self::InvalidPageLabels,
Self::TagElementNotOpen,
Self::TagElementUnclosed,
Self::ProfileVersionConflict,
Self::MissingTitle,
Self::MissingLang,
Self::MissingAltText,
Self::UntaggedContent,
Self::HeadingLevelSkipped,
Self::UnnumberedHeadingMisused,
Self::InvalidStructureNesting,
Self::LinkWithoutStructure,
Self::LinkWithoutContents,
Self::FontNotEmbedded,
Self::GlyphWithoutUnicode,
Self::DeviceColorWithoutOutputIntent,
Self::EmbeddedFileForbidden,
Self::EmbeddedFileWithoutMimeType,
Self::FlowContentTooLarge,
Self::FlowLayoutUnstable,
Self::InvalidDocument,
Self::TemplateDataMissing,
Self::TemplateDataType,
Self::TemplateTooLarge,
Self::RenderTooLarge,
Self::RenderFailed,
Self::RenderBackendUnavailable,
Self::ExportFailed,
Self::ModelFailed,
Self::ModelResultUnexpected,
Self::ModelNeedsHost,
Self::InterchangeUnknownFormat,
Self::InterchangeMalformed,
Self::InterchangeDtd,
Self::SubmitPdfRefused,
Self::SubmitUrlRefused,
Self::InterchangeTooLarge,
Self::Cancelled,
Self::JobFinished,
Self::DocumentChanged,
Self::RevisionIndexOutOfRange,
Self::NoBookmarks,
Self::SoundUnavailable,
Self::BuilderFinished,
Self::Disposed,
Self::InvalidArgument,
Self::SourceBudgetExceeded,
Self::UnknownOption,
Self::InvalidCommandLine,
Self::InvalidPageRange,
Self::BinaryOutputToTerminal,
Self::UnknownCode,
Self::OverwriteRefused,
Self::InputUnreadable,
Self::OutputUnwritable,
Self::PathOutsideRoots,
];
#[must_use]
pub const fn from_code(code: &str) -> Option<Self> {
let mut rest = Self::ALL;
while let [first, tail @ ..] = rest {
if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
return Some(*first);
}
rest = tail;
}
None
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::NotPdf => "not-pdf",
Self::MissingRoot => "missing-root",
Self::ReferenceCycle => "reference-cycle",
Self::LimitExceeded => "limit-exceeded",
Self::Strict => "strict",
Self::DataPending => "data-pending",
Self::Source => "source",
Self::Type => "type",
Self::InvalidStructure => "invalid-structure",
Self::UnsetObject => "unset-object",
Self::RepairedBase => "repaired-base",
Self::EncryptedBase => "encrypted-base",
Self::PasswordRequired => "password-required",
Self::WrongPassword => "wrong-password",
Self::UnsupportedSecurityHandler => "unsupported-security-handler",
Self::UnexpectedEof => "unexpected-eof",
Self::Syntax => "syntax",
Self::UnsupportedFilter => "unsupported-filter",
Self::Decompress => "decompress",
Self::NestedTransaction => "nested-transaction",
Self::NoTransaction => "no-transaction",
Self::UnknownPage => "unknown-page",
Self::DirectPage => "direct-page",
Self::UnsupportedVersion => "unsupported-version",
Self::InvalidOpLog => "invalid-op-log",
Self::SavedNotRebased => "saved-not-rebased",
Self::NoPendingSave => "no-pending-save",
Self::MalformedXmp => "malformed-xmp",
Self::UnknownSource => "unknown-source",
Self::OpenActionNotDestination => "open-action-not-destination",
Self::UnknownOutlineItem => "unknown-outline-item",
Self::DirectOutlineItem => "direct-outline-item",
Self::OutlineNotASibling => "outline-not-a-sibling",
Self::OutlineMoveIntoItself => "outline-move-into-itself",
Self::UnknownNamedDestination => "unknown-named-destination",
Self::NamedDestinationExists => "named-destination-exists",
Self::EmptyDestinationName => "empty-destination-name",
Self::LinkUriRefused => "link-uri-refused",
Self::ViewNotFinite => "view-not-finite",
Self::XmpClaimReadOnly => "xmp-claim-read-only",
Self::InvalidXmpPacket => "invalid-xmp-packet",
Self::InvalidXmpProperty => "invalid-xmp-property",
Self::NoPagesLeft => "no-pages-left",
Self::InvalidOp => "invalid-op",
Self::UnknownAnnotation => "unknown-annotation",
Self::AnnotationLocked => "annotation-locked",
Self::AnnotationNotEditable => "annotation-not-editable",
Self::NotALink => "not-a-link",
Self::LinkNotTagged => "link-not-tagged",
Self::AppearanceUnavailable => "appearance-unavailable",
Self::AppearanceNeedsText => "appearance-needs-text",
Self::AnnotationGlyphMissing => "annotation-glyph-missing",
Self::AnnotationFontInvalid => "annotation-font-invalid",
Self::StampImageInvalid => "stamp-image-invalid",
Self::InvalidLabelRanges => "invalid-label-ranges",
Self::ContentObjectStale => "content-object-stale",
Self::ContentNotEditable => "content-not-editable",
Self::UnknownBlob => "unknown-blob",
Self::ImagesUnavailable => "images-unavailable",
Self::FlattenWidget => "flatten-widget",
Self::UnknownAttachment => "unknown-attachment",
Self::AttachmentTooLarge => "attachment-too-large",
Self::UnknownField => "unknown-field",
Self::FieldIsSignature => "field-is-signature",
Self::SignFieldSigned => "sign-field-signed",
Self::SignCertifyNotFirst => "sign-certify-not-first",
Self::FieldValueInvalid => "field-value-invalid",
Self::FieldNameTaken => "field-name-taken",
Self::FieldNameInvalid => "field-name-invalid",
Self::PdfaFieldActions => "pdfa-field-actions",
Self::TabOrderNeedsStructure => "tab-order-needs-structure",
Self::TabOrderInvalid => "tab-order-invalid",
Self::ContentIdInUse => "content-id-in-use",
Self::UnknownContentObject => "unknown-content-object",
Self::UnknownPageMark => "unknown-page-mark",
Self::ContentObjectInvalid => "content-object-invalid",
Self::ContentNeedsAltText => "content-needs-alt-text",
Self::ContentGlyphMissing => "content-glyph-missing",
Self::ContentFontInvalid => "content-font-invalid",
Self::ContentFontNotEmbeddable => "content-font-not-embeddable",
Self::EncryptionNoPassword => "encryption-no-password",
Self::EncryptionPdfaConflict => "encryption-pdfa-conflict",
Self::SecretMissing => "secret-missing",
Self::OwnerPasswordRequired => "owner-password-required",
Self::NotEncrypted => "not-encrypted",
Self::Sink => "sink",
Self::NotRebased => "not-rebased",
Self::SinkNotEmpty => "sink-not-empty",
Self::WouldInvalidateSignatures => "would-invalidate-signatures",
Self::RequiresRewrite => "requires-rewrite",
Self::EncryptionIncomplete => "encryption-incomplete",
Self::EncryptionNoEntropy => "encryption-no-entropy",
Self::SignPlaceholderTooSmall => "sign-placeholder-too-small",
Self::SignKeyUnsupported => "sign-key-unsupported",
Self::SignSignerFailed => "sign-signer-failed",
Self::SignDocumentChanged => "sign-document-changed",
Self::SignatureMalformed => "signature-malformed",
Self::SignatureAlgorithmUnsupported => "signature-algorithm-unsupported",
Self::InvalidFont => "invalid-font",
Self::CollectionIndex => "collection-index",
Self::UnknownAxis => "unknown-axis",
Self::FontNotEmbeddable => "font-not-embeddable",
Self::MissingGlyph => "missing-glyph",
Self::GlyphOutOfRange => "glyph-out-of-range",
Self::UnknownFont => "unknown-font",
Self::SubsetFailed => "subset-failed",
Self::InvalidAxisValue => "invalid-axis-value",
Self::WrongDocument => "wrong-document",
Self::InvalidFeature => "invalid-feature",
Self::InvalidTextRange => "invalid-text-range",
Self::InvalidSpans => "invalid-spans",
Self::UnsupportedLayoutOption => "unsupported-layout-option",
Self::FontMismatch => "font-mismatch",
Self::EncodingFull => "encoding-full",
Self::FontNotShapable => "font-not-shapable",
Self::InvalidImage => "invalid-image",
Self::UnsupportedImage => "unsupported-image",
Self::ImageTooLarge => "image-too-large",
Self::ImageDataLength => "image-data-length",
Self::InvalidIccProfile => "invalid-icc-profile",
Self::ColorComponents => "color-components",
Self::InvalidColor => "invalid-color",
Self::InvalidGeometry => "invalid-geometry",
Self::TextOverflow => "text-overflow",
Self::PageIndexOutOfRange => "page-index-out-of-range",
Self::UnknownDestination => "unknown-destination",
Self::InvalidPageLabels => "invalid-page-labels",
Self::TagElementNotOpen => "tag-element-not-open",
Self::TagElementUnclosed => "tag-element-unclosed",
Self::ProfileVersionConflict => "profile-version-conflict",
Self::MissingTitle => "missing-title",
Self::MissingLang => "missing-lang",
Self::MissingAltText => "missing-alt-text",
Self::UntaggedContent => "untagged-content",
Self::HeadingLevelSkipped => "heading-level-skipped",
Self::UnnumberedHeadingMisused => "unnumbered-heading-misused",
Self::InvalidStructureNesting => "invalid-structure-nesting",
Self::LinkWithoutStructure => "link-without-structure",
Self::LinkWithoutContents => "link-without-contents",
Self::FontNotEmbedded => "font-not-embedded",
Self::GlyphWithoutUnicode => "glyph-without-unicode",
Self::DeviceColorWithoutOutputIntent => "device-color-without-output-intent",
Self::EmbeddedFileForbidden => "embedded-file-forbidden",
Self::EmbeddedFileWithoutMimeType => "embedded-file-without-mime-type",
Self::FlowContentTooLarge => "flow-content-too-large",
Self::FlowLayoutUnstable => "flow-layout-unstable",
Self::InvalidDocument => "invalid-document",
Self::TemplateDataMissing => "template-data-missing",
Self::TemplateDataType => "template-data-type",
Self::TemplateTooLarge => "template-too-large",
Self::RenderTooLarge => "render-too-large",
Self::RenderFailed => "render-failed",
Self::RenderBackendUnavailable => "render-backend-unavailable",
Self::ExportFailed => "export-failed",
Self::ModelFailed => "model-failed",
Self::ModelResultUnexpected => "model-result-unexpected",
Self::ModelNeedsHost => "model-needs-host",
Self::InterchangeUnknownFormat => "interchange-unknown-format",
Self::InterchangeMalformed => "interchange-malformed",
Self::InterchangeDtd => "interchange-dtd",
Self::SubmitPdfRefused => "submit-pdf-refused",
Self::SubmitUrlRefused => "submit-url-refused",
Self::InterchangeTooLarge => "interchange-too-large",
Self::Cancelled => "cancelled",
Self::JobFinished => "job-finished",
Self::DocumentChanged => "document-changed",
Self::RevisionIndexOutOfRange => "revision-index-out-of-range",
Self::NoBookmarks => "no-bookmarks",
Self::SoundUnavailable => "sound-unavailable",
Self::BuilderFinished => "builder-finished",
Self::Disposed => "disposed",
Self::InvalidArgument => "invalid-argument",
Self::SourceBudgetExceeded => "source-budget-exceeded",
Self::UnknownOption => "unknown-option",
Self::InvalidCommandLine => "invalid-command-line",
Self::InvalidPageRange => "invalid-page-range",
Self::BinaryOutputToTerminal => "binary-output-to-terminal",
Self::UnknownCode => "unknown-code",
Self::OverwriteRefused => "overwrite-refused",
Self::InputUnreadable => "input-unreadable",
Self::OutputUnwritable => "output-unwritable",
Self::PathOutsideRoots => "path-outside-roots",
}
}
#[must_use]
pub const fn kind(self) -> ErrorKind {
match self {
Self::NotPdf => ErrorKind::Input,
Self::MissingRoot => ErrorKind::Input,
Self::ReferenceCycle => ErrorKind::Input,
Self::LimitExceeded => ErrorKind::Limit,
Self::Strict => ErrorKind::Input,
Self::DataPending => ErrorKind::State,
Self::Source => ErrorKind::Io,
Self::Type => ErrorKind::Input,
Self::InvalidStructure => ErrorKind::Input,
Self::UnsetObject => ErrorKind::Internal,
Self::RepairedBase => ErrorKind::State,
Self::EncryptedBase => ErrorKind::Unsupported,
Self::PasswordRequired => ErrorKind::Security,
Self::WrongPassword => ErrorKind::Security,
Self::UnsupportedSecurityHandler => ErrorKind::Unsupported,
Self::UnexpectedEof => ErrorKind::Input,
Self::Syntax => ErrorKind::Input,
Self::UnsupportedFilter => ErrorKind::Unsupported,
Self::Decompress => ErrorKind::Input,
Self::NestedTransaction => ErrorKind::State,
Self::NoTransaction => ErrorKind::State,
Self::UnknownPage => ErrorKind::Usage,
Self::DirectPage => ErrorKind::Unsupported,
Self::UnsupportedVersion => ErrorKind::Unsupported,
Self::InvalidOpLog => ErrorKind::Input,
Self::SavedNotRebased => ErrorKind::State,
Self::NoPendingSave => ErrorKind::State,
Self::MalformedXmp => ErrorKind::Input,
Self::UnknownSource => ErrorKind::Usage,
Self::OpenActionNotDestination => ErrorKind::Usage,
Self::UnknownOutlineItem => ErrorKind::Usage,
Self::DirectOutlineItem => ErrorKind::Unsupported,
Self::OutlineNotASibling => ErrorKind::Usage,
Self::OutlineMoveIntoItself => ErrorKind::Usage,
Self::UnknownNamedDestination => ErrorKind::Usage,
Self::NamedDestinationExists => ErrorKind::Usage,
Self::EmptyDestinationName => ErrorKind::Usage,
Self::LinkUriRefused => ErrorKind::Usage,
Self::ViewNotFinite => ErrorKind::Usage,
Self::XmpClaimReadOnly => ErrorKind::Usage,
Self::InvalidXmpPacket => ErrorKind::Input,
Self::InvalidXmpProperty => ErrorKind::Usage,
Self::NoPagesLeft => ErrorKind::Usage,
Self::InvalidOp => ErrorKind::Usage,
Self::UnknownAnnotation => ErrorKind::Usage,
Self::AnnotationLocked => ErrorKind::State,
Self::AnnotationNotEditable => ErrorKind::Unsupported,
Self::NotALink => ErrorKind::Usage,
Self::LinkNotTagged => ErrorKind::Unsupported,
Self::AppearanceUnavailable => ErrorKind::Unsupported,
Self::AppearanceNeedsText => ErrorKind::Unsupported,
Self::AnnotationGlyphMissing => ErrorKind::Usage,
Self::AnnotationFontInvalid => ErrorKind::Usage,
Self::StampImageInvalid => ErrorKind::Usage,
Self::InvalidLabelRanges => ErrorKind::Usage,
Self::ContentObjectStale => ErrorKind::State,
Self::ContentNotEditable => ErrorKind::Unsupported,
Self::UnknownBlob => ErrorKind::Usage,
Self::ImagesUnavailable => ErrorKind::Unsupported,
Self::FlattenWidget => ErrorKind::Usage,
Self::UnknownAttachment => ErrorKind::Usage,
Self::AttachmentTooLarge => ErrorKind::Limit,
Self::UnknownField => ErrorKind::Usage,
Self::FieldIsSignature => ErrorKind::Usage,
Self::SignFieldSigned => ErrorKind::Usage,
Self::SignCertifyNotFirst => ErrorKind::Usage,
Self::FieldValueInvalid => ErrorKind::Usage,
Self::FieldNameTaken => ErrorKind::Usage,
Self::FieldNameInvalid => ErrorKind::Usage,
Self::PdfaFieldActions => ErrorKind::Usage,
Self::TabOrderNeedsStructure => ErrorKind::Usage,
Self::TabOrderInvalid => ErrorKind::Usage,
Self::ContentIdInUse => ErrorKind::Usage,
Self::UnknownContentObject => ErrorKind::Usage,
Self::UnknownPageMark => ErrorKind::Usage,
Self::ContentObjectInvalid => ErrorKind::Usage,
Self::ContentNeedsAltText => ErrorKind::Usage,
Self::ContentGlyphMissing => ErrorKind::Usage,
Self::ContentFontInvalid => ErrorKind::Usage,
Self::ContentFontNotEmbeddable => ErrorKind::Usage,
Self::EncryptionNoPassword => ErrorKind::Usage,
Self::EncryptionPdfaConflict => ErrorKind::State,
Self::SecretMissing => ErrorKind::Usage,
Self::OwnerPasswordRequired => ErrorKind::Security,
Self::NotEncrypted => ErrorKind::State,
Self::Sink => ErrorKind::Io,
Self::NotRebased => ErrorKind::State,
Self::SinkNotEmpty => ErrorKind::Usage,
Self::WouldInvalidateSignatures => ErrorKind::Security,
Self::RequiresRewrite => ErrorKind::State,
Self::EncryptionIncomplete => ErrorKind::Security,
Self::EncryptionNoEntropy => ErrorKind::Usage,
Self::SignPlaceholderTooSmall => ErrorKind::Limit,
Self::SignKeyUnsupported => ErrorKind::Unsupported,
Self::SignSignerFailed => ErrorKind::Io,
Self::SignDocumentChanged => ErrorKind::State,
Self::SignatureMalformed => ErrorKind::Security,
Self::SignatureAlgorithmUnsupported => ErrorKind::Unsupported,
Self::InvalidFont => ErrorKind::Input,
Self::CollectionIndex => ErrorKind::Usage,
Self::UnknownAxis => ErrorKind::Usage,
Self::FontNotEmbeddable => ErrorKind::Usage,
Self::MissingGlyph => ErrorKind::Input,
Self::GlyphOutOfRange => ErrorKind::Usage,
Self::UnknownFont => ErrorKind::Usage,
Self::SubsetFailed => ErrorKind::Unsupported,
Self::InvalidAxisValue => ErrorKind::Usage,
Self::WrongDocument => ErrorKind::Usage,
Self::InvalidFeature => ErrorKind::Usage,
Self::InvalidTextRange => ErrorKind::Usage,
Self::InvalidSpans => ErrorKind::Usage,
Self::UnsupportedLayoutOption => ErrorKind::Unsupported,
Self::FontMismatch => ErrorKind::Usage,
Self::EncodingFull => ErrorKind::Limit,
Self::FontNotShapable => ErrorKind::Unsupported,
Self::InvalidImage => ErrorKind::Input,
Self::UnsupportedImage => ErrorKind::Unsupported,
Self::ImageTooLarge => ErrorKind::Limit,
Self::ImageDataLength => ErrorKind::Usage,
Self::InvalidIccProfile => ErrorKind::Input,
Self::ColorComponents => ErrorKind::Usage,
Self::InvalidColor => ErrorKind::Usage,
Self::InvalidGeometry => ErrorKind::Usage,
Self::TextOverflow => ErrorKind::Usage,
Self::PageIndexOutOfRange => ErrorKind::Usage,
Self::UnknownDestination => ErrorKind::Usage,
Self::InvalidPageLabels => ErrorKind::Usage,
Self::TagElementNotOpen => ErrorKind::Usage,
Self::TagElementUnclosed => ErrorKind::Usage,
Self::ProfileVersionConflict => ErrorKind::Usage,
Self::MissingTitle => ErrorKind::Usage,
Self::MissingLang => ErrorKind::Usage,
Self::MissingAltText => ErrorKind::Usage,
Self::UntaggedContent => ErrorKind::Usage,
Self::HeadingLevelSkipped => ErrorKind::Usage,
Self::UnnumberedHeadingMisused => ErrorKind::Usage,
Self::InvalidStructureNesting => ErrorKind::Usage,
Self::LinkWithoutStructure => ErrorKind::Usage,
Self::LinkWithoutContents => ErrorKind::Usage,
Self::FontNotEmbedded => ErrorKind::Usage,
Self::GlyphWithoutUnicode => ErrorKind::Usage,
Self::DeviceColorWithoutOutputIntent => ErrorKind::Usage,
Self::EmbeddedFileForbidden => ErrorKind::Usage,
Self::EmbeddedFileWithoutMimeType => ErrorKind::Usage,
Self::FlowContentTooLarge => ErrorKind::Usage,
Self::FlowLayoutUnstable => ErrorKind::Internal,
Self::InvalidDocument => ErrorKind::Usage,
Self::TemplateDataMissing => ErrorKind::Usage,
Self::TemplateDataType => ErrorKind::Usage,
Self::TemplateTooLarge => ErrorKind::Usage,
Self::RenderTooLarge => ErrorKind::Limit,
Self::RenderFailed => ErrorKind::Input,
Self::RenderBackendUnavailable => ErrorKind::Io,
Self::ExportFailed => ErrorKind::Internal,
Self::ModelFailed => ErrorKind::Internal,
Self::ModelResultUnexpected => ErrorKind::Usage,
Self::ModelNeedsHost => ErrorKind::Usage,
Self::InterchangeUnknownFormat => ErrorKind::Input,
Self::InterchangeMalformed => ErrorKind::Input,
Self::InterchangeDtd => ErrorKind::Security,
Self::SubmitPdfRefused => ErrorKind::Security,
Self::SubmitUrlRefused => ErrorKind::Security,
Self::InterchangeTooLarge => ErrorKind::Limit,
Self::Cancelled => ErrorKind::Cancelled,
Self::JobFinished => ErrorKind::State,
Self::DocumentChanged => ErrorKind::State,
Self::RevisionIndexOutOfRange => ErrorKind::Usage,
Self::NoBookmarks => ErrorKind::Usage,
Self::SoundUnavailable => ErrorKind::Usage,
Self::BuilderFinished => ErrorKind::State,
Self::Disposed => ErrorKind::State,
Self::InvalidArgument => ErrorKind::Usage,
Self::SourceBudgetExceeded => ErrorKind::Limit,
Self::UnknownOption => ErrorKind::Usage,
Self::InvalidCommandLine => ErrorKind::Usage,
Self::InvalidPageRange => ErrorKind::Usage,
Self::BinaryOutputToTerminal => ErrorKind::Usage,
Self::UnknownCode => ErrorKind::Usage,
Self::OverwriteRefused => ErrorKind::State,
Self::InputUnreadable => ErrorKind::Io,
Self::OutputUnwritable => ErrorKind::Io,
Self::PathOutsideRoots => ErrorKind::Security,
}
}
#[must_use]
pub const fn summary(self) -> &'static str {
match self {
Self::NotPdf => "the input does not look like a PDF at all",
Self::MissingRoot => "no document catalog (/Root) was found, even after repair",
Self::ReferenceCycle => "a reference chain or the page tree loops back on itself",
Self::LimitExceeded => "a hard Limits value was exceeded",
Self::Strict => "strict mode refused something the tolerant reader would have repaired",
Self::DataPending => "the ByteSource has not fetched the byte ranges the call needs yet",
Self::Source => "the ByteSource failed to read",
Self::Type => "an object had a different type than the structure requires",
Self::InvalidStructure => "an object stream, xref section or filter parameter was malformed",
Self::UnsetObject => "a writer object number was reserved but never given a value",
Self::RepairedBase => "an incremental update was requested for a document whose xref needed repair",
Self::EncryptedBase => "a save of an encrypted document was requested",
Self::PasswordRequired => "the document is encrypted with a user password and none was given",
Self::WrongPassword => "the given password is neither the user nor the owner password",
Self::UnsupportedSecurityHandler => "the document uses a security handler Lamina PDF cannot decrypt",
Self::UnexpectedEof => "the input ended before a complete token or object was read",
Self::Syntax => "a token or structure did not match the PDF grammar",
Self::UnsupportedFilter => "a stream uses a filter Lamina PDF does not implement",
Self::Decompress => "compressed stream data was corrupt",
Self::NestedTransaction => "a transaction was started, or undo or redo called, while one is open",
Self::NoTransaction => "apply, commit or rollback was called without an open transaction",
Self::UnknownPage => "an op names a page the document does not have",
Self::DirectPage => "the page is a direct dictionary, which ops cannot edit yet",
Self::UnsupportedVersion => "an op log has a schema version this reader does not know",
Self::InvalidOpLog => "an op log does not parse: an unknown op or field, a bad value, or not JSON",
Self::SavedNotRebased => "the document was saved to a sink Lamina PDF cannot read back and waits for rebase",
Self::NoPendingSave => "rebase was called without a save waiting for it",
Self::MalformedXmp => "a metadata edit would replace the document's XMP packet, which can't be read, losing what it holds",
Self::UnknownSource => "an op or a call names a source document that was not added to the session",
Self::OpenActionNotDestination => "an op would replace or remove the document's open action, which is an action other than a destination",
Self::UnknownOutlineItem => "an outline op names a bookmark the outline does not have",
Self::DirectOutlineItem => "the bookmark is stored inside another item rather than as an object of its own, so outline ops can't name it yet",
Self::OutlineNotASibling => "the position names a bookmark that is not a child of the parent the op names",
Self::OutlineMoveIntoItself => "a move would put a bookmark inside itself or one of its descendants",
Self::UnknownNamedDestination => "the op names a destination the file does not define",
Self::NamedDestinationExists => "a rename to a name another destination already has",
Self::EmptyDestinationName => "a destination name is empty",
Self::LinkUriRefused => "a web address that isn't an absolute http, https or mailto address in plain ASCII",
Self::ViewNotFinite => "a destination's coordinates and zoom must be finite numbers",
Self::XmpClaimReadOnly => "an XMP edit would change the file's PDF/A or PDF/UA identification, which only conversion or a check may set",
Self::InvalidXmpPacket => "the XMP packet given to replace the document's doesn't parse",
Self::InvalidXmpProperty => "an XMP property edit names a property, or gives a value, that can't be written",
Self::NoPagesLeft => "a page deletion would leave the document with no pages",
Self::InvalidOp => "an op's values are out of range, such as a page count or a page size",
Self::UnknownAnnotation => "the op names an annotation that no page of the document lists",
Self::AnnotationLocked => "the annotation's flags forbid the change: Locked forbids deleting it or changing its properties, LockedContents changing its contents",
Self::AnnotationNotEditable => "the annotation can't be edited by the annotation ops: it is a form field's widget, or a direct dictionary with no object of its own",
Self::NotALink => "a link op names an annotation that isn't a link",
Self::LinkNotTagged => "the file claims PDF/UA-1 but has no structure tree for a new link to join",
Self::AppearanceUnavailable => "the document has no appearance generator, so it can't draw a new annotation",
Self::AppearanceNeedsText => "drawing this text box needs text layout that this build of Lamina PDF leaves out: a font given by its bytes, or a fallback font",
Self::AnnotationGlyphMissing => "a character of a text box is in none of its fonts, so it can't be drawn",
Self::AnnotationFontInvalid => "a text box's font bytes aren't a font Lamina PDF can read and embed",
Self::StampImageInvalid => "an image stamp's bytes aren't a JPEG or PNG image Lamina PDF can read",
Self::InvalidLabelRanges => "page label ranges whose first isn't on the first page, that are out of page order or share a page, or that number from 0",
Self::ContentObjectStale => "an edit names a content object whose bytes are no longer what the edit expects, so it would change another object",
Self::ContentNotEditable => "the content can't be edited: its font, its writing direction, the order of its glyphs, a clip it sets or the state it draws in is one Lamina PDF can't change safely, or it can't be read",
Self::UnknownBlob => "an op names bytes by an ID that were not added to the session",
Self::ImagesUnavailable => "the document has no image writer, so it can't put a replacement image in the file",
Self::FlattenWidget => "flattening names a form field's widget, which annotation flattening leaves alone",
Self::UnknownAttachment => "an attachment op names an attachment the document doesn't hold",
Self::AttachmentTooLarge => "a file to attach is larger than the document can read back out, so it wasn't attached",
Self::UnknownField => "a form op names a field the form doesn't have",
Self::FieldIsSignature => "a form-filling op names a signature field, whose value only signing writes",
Self::SignFieldSigned => "the signature field a Sign op names already holds a signature",
Self::SignCertifyNotFirst => "a Sign op asks to certify a document that already holds a signature",
Self::FieldValueInvalid => "a value doesn't fit its form field: another kind of value, text over the maximum length, an option or state the field doesn't have, the wrong number of choices, or text its format or range refuses",
Self::FieldNameTaken => "a form field with this fully qualified name exists already (a new field's name, or the name a field is renamed to)",
Self::FieldNameInvalid => "a form field's name (new, or a rename's) is empty, has an empty part between periods or a control character, or sits below a field that has widgets",
Self::PdfaFieldActions => "a push button's form action, or a field's format, validation or calculation script, is one that PDF/A forbids",
Self::TabOrderNeedsStructure => "a tab order needs the document's structure: Structure on a file that isn't tagged, or a custom order on a file that claims PDF/UA-1",
Self::TabOrderInvalid => "a custom tab order doesn't list every widget of the page exactly once",
Self::ContentIdInUse => "an object added to a page has an ID that another object Lamina PDF added to that page already has",
Self::UnknownContentObject => "the op names an added object that the page doesn't draw",
Self::UnknownPageMark => "the op names a page mark (a watermark, background, header or footer, or Bates number) that the page doesn't draw",
Self::ContentObjectInvalid => "an added object's bytes aren't a JPEG or PNG image, or a PDF with the page it names, that Lamina PDF can read",
Self::ContentNeedsAltText => "an image added to a file that claims PDF/UA-1 has no alternate text, which PDF/UA-1 requires of a figure",
Self::ContentGlyphMissing => "a character of text added to a page is in none of its fonts, so it can't be drawn",
Self::ContentFontInvalid => "a font given for text added to a page isn't a font Lamina PDF can read and embed",
Self::ContentFontNotEmbeddable => "a font given for text added to a page forbids embedding in its OS/2 fsType, so the page can't keep it",
Self::EncryptionNoPassword => "a request to encrypt a file gave neither a user password nor an owner password",
Self::EncryptionPdfaConflict => "a request to encrypt a file that claims PDF/A, which forbids encryption",
Self::SecretMissing => "an operation needs a password that an op log left out, since logs never store passwords",
Self::OwnerPasswordRequired => "a request to change or remove a file's protection, or to copy its pages into a document without it, when it was opened with a password that restricts what it allows",
Self::NotEncrypted => "a request to remove the protection of a file that isn't encrypted",
Self::Sink => "the sink failed to take the bytes or could not give them back",
Self::NotRebased => "the output was written, but rebasing the document onto it failed",
Self::SinkNotEmpty => "the sink already held bytes before the save started",
Self::WouldInvalidateSignatures => "the save would break one or more signatures",
Self::RequiresRewrite => "an incremental save was requested but only a full rewrite is safe",
Self::EncryptionIncomplete => "a string or stream could not be encrypted, so the save wrote nothing",
Self::EncryptionNoEntropy => "a save that encrypts the file was given no random bytes to encrypt with",
Self::SignPlaceholderTooSmall => "the signature doesn't fit the space reserved for it in the file",
Self::SignKeyUnsupported => "the signing certificate or its key isn't one lamina signs with",
Self::SignSignerFailed => "the signer couldn't sign, or what it returned isn't a signature of its key's algorithm",
Self::SignDocumentChanged => "the document changed after the signature was prepared, or isn't the document it was prepared for",
Self::SignatureMalformed => "a signature's dictionary, /ByteRange or /Contents breaks a structural rule, so the signature is never valid",
Self::SignatureAlgorithmUnsupported => "a signature uses an algorithm, curve, key size or sub-filter the validator does not accept, so it is neither valid nor invalid",
Self::InvalidFont => "font bytes could not be read as a font",
Self::CollectionIndex => "a font collection member past the end of the collection was asked for",
Self::UnknownAxis => "an instance was asked for on a variation axis the font does not have",
Self::FontNotEmbeddable => "the font's OS/2 fsType forbids embedding",
Self::MissingGlyph => "the font has no glyph for a character of the text",
Self::GlyphOutOfRange => "a glyph ID at or past the font's glyph count was used",
Self::UnknownFont => "a FontKey was used with a registry that did not hand it out",
Self::SubsetFailed => "subsetting a font failed",
Self::InvalidAxisValue => "a variation axis value was NaN or infinite",
Self::WrongDocument => "finish_fonts was given a document the registry did not reserve its fonts in",
Self::InvalidFeature => "an OpenType feature setting did not parse",
Self::InvalidTextRange => "a byte range was out of bounds or not on character boundaries of the text",
Self::InvalidSpans => "the styled spans given for a paragraph do not cover its text once, in order",
Self::UnsupportedLayoutOption => "a layout option that is not implemented yet was asked for",
Self::FontMismatch => "a shaped run was given with a font key for a different font than it was shaped with",
Self::EncodingFull => "a standard 14 font has no free one-byte code left for another glyph",
Self::FontNotShapable => "a standard 14 font was given to shaping or layout, which need a font program",
Self::InvalidImage => "image bytes are not a readable image of the format they were given as",
Self::UnsupportedImage => "the image uses a feature that PDF or Lamina PDF does not support",
Self::ImageTooLarge => "the image needs more memory than the builder allows (a decoded PNG over 256 MiB, or raw dimensions whose size overflows)",
Self::ImageDataLength => "raw image samples are not width x height x channels bytes long",
Self::InvalidIccProfile => "the bytes are not a usable ICC profile",
Self::ColorComponents => "a colour has the wrong number of components for its colour space",
Self::InvalidColor => "a colour string is not of the form #rgb or #rrggbb",
Self::InvalidGeometry => "a page size, box, /UserUnit, drawing value (coordinate, matrix, line width, dash, miter limit) or image size is not usable",
Self::TextOverflow => "a text box's lines don't all fit its height and its options asked for an error",
Self::PageIndexOutOfRange => "a link, outline item or destination names a page index the document doesn't have",
Self::UnknownDestination => "a link or outline item names a destination that was never defined",
Self::InvalidPageLabels => "page label ranges that don't start at page 0, don't increase, start past the last page or number from 0",
Self::TagElementNotOpen => "a structure element resumed or closed isn't open",
Self::TagElementUnclosed => "structure elements opened across pages were never closed",
Self::ProfileVersionConflict => "the PDF version asked for is one the profile doesn't allow (PDF/UA-1, PDF/A-2 and PDF/A-3 are based on PDF 1.7)",
Self::MissingTitle => "PDF/UA-1 needs a document title, and the metadata gives none",
Self::MissingLang => "PDF/UA-1 needs the document's natural language, and none was set",
Self::MissingAltText => "a Figure or Formula has no alternate text (/Alt or /ActualText), which PDF/UA-1 requires",
Self::UntaggedContent => "content was drawn outside every structure element and artifact, which PDF/UA-1 forbids",
Self::HeadingLevelSkipped => "a heading skips a level (the first is not H1, or an H3 follows an H1), which PDF/UA-1 forbids",
Self::UnnumberedHeadingMisused => "an unnumbered H heading shares its parent with another H, or the document also uses H1-H6, which PDF/UA-1 forbids",
Self::InvalidStructureNesting => "a table or list element sits in a parent its type doesn't allow (a TD outside a TR, a P directly in a Table)",
Self::LinkWithoutStructure => "a link annotation has no Link structure element (it was drawn inside an artifact), which PDF/UA-1 forbids",
Self::LinkWithoutContents => "a link annotation has no description (/Contents), which PDF/UA-1 requires",
Self::FontNotEmbedded => "a standard 14 font, which is never embedded, was used under a profile that needs every font embedded",
Self::GlyphWithoutUnicode => "a glyph was drawn without a Unicode value, which PDF/A-2u and PDF/UA-1 forbid",
Self::DeviceColorWithoutOutputIntent => "a DeviceCMYK colour or image was used, but the PDF/A output intent is sRGB",
Self::EmbeddedFileForbidden => "PDF/A-2 doesn't allow attached files that aren't PDF/A themselves",
Self::EmbeddedFileWithoutMimeType => "an attached file has no MIME type, which every PDF/A profile requires",
Self::FlowContentTooLarge => "a line or a figure of a flow is taller than the page's body, so no page can hold it",
Self::FlowLayoutUnstable => "a flow's contents page kept changing its page numbers after four layouts",
Self::InvalidDocument => "a laminapdf.document/1 document has an unknown key, a missing one or a value of the wrong kind",
Self::TemplateDataMissing => "a template's $data, $each or $item points to a value the data doesn't have",
Self::TemplateDataType => "a template's placeholder found data of the wrong kind: $each over something that isn't a list, or text from an object",
Self::TemplateTooLarge => "a template would fill in more values, or nest deeper, than a document may hold",
Self::RenderTooLarge => "the requested tile is larger than the render limits allow; nothing was allocated",
Self::RenderFailed => "the render engine could not open the document or draw the page",
Self::RenderBackendUnavailable => "the render engine is not available: its library or module could not be loaded",
Self::ExportFailed => "an export's PNG, JPEG or TIFF encoder failed on a page that was drawn",
Self::ModelFailed => "a layout model, OCR engine or page renderer plugged into an extraction failed; the extraction stops with no partial result",
Self::ModelResultUnexpected => "a model result was handed to an extraction job that hadn't asked for it, or was the other model's result",
Self::ModelNeedsHost => "an extraction in one call was given a model whose results only the host can give: a host model, or a plug-in model without a page renderer",
Self::InterchangeUnknownFormat => "the bytes given to import are neither XFDF nor FDF, nor JSON for form data",
Self::InterchangeMalformed => "the XFDF, FDF or form data JSON file doesn't read; the error names the line where reading stopped",
Self::InterchangeDtd => "the XFDF file declares a DTD, which could define entities that expand without end or read other files, so it is refused",
Self::SubmitPdfRefused => "a form action asks to send the whole PDF, which Lamina PDF never does: only field values leave the device",
Self::SubmitUrlRefused => "a form action's address isn't an https: address, so nothing is sent",
Self::InterchangeTooLarge => "the exchange file is larger than the document's limits allow",
Self::Cancelled => "a CancelToken stopped the work; the job is finished and returned no partial result",
Self::JobFinished => "a job was stepped after it had finished, failed or been cancelled",
Self::DocumentChanged => "the document a job or a contents listing was made from changed (an edit, undo, redo, save or rebase), or a different document was passed to step",
Self::RevisionIndexOutOfRange => "an earlier revision was asked for by an index past the file's last revision",
Self::NoBookmarks => "a contents page was asked for, but no bookmark goes to a page of the document, so it would list nothing",
Self::SoundUnavailable => "a sound comment was asked for as WAV, but the annotation isn't a Sound annotation, or its samples are compressed or in a format PDF doesn't allow",
Self::BuilderFinished => "a builder or one of its pages was used after it finished",
Self::Disposed => "a document, builder or other handle was used after free(), or after the using block that held it ended",
Self::InvalidArgument => "a value passed to a binding does not have the shape its type declares",
Self::SourceBudgetExceeded => "a sparse source was given more bytes than its byte budget allows",
Self::UnknownOption => "an options record passed to a binding has a key Lamina PDF does not know",
Self::InvalidCommandLine => "the command line doesn't parse: an unknown command or flag, a missing argument, a bad value, or stdin named twice",
Self::InvalidPageRange => "a page range doesn't fit the grammar, or names a page the document lacks",
Self::BinaryOutputToTerminal => "the command would write a PDF to standard output, and standard output is a terminal",
Self::UnknownCode => "explain was given a code that isn't a Lamina PDF error or warning code",
Self::OverwriteRefused => "the output file exists, or the command would modify its input in place, and --force wasn't given",
Self::InputUnreadable => "an input file, standard input or the password file couldn't be read",
Self::OutputUnwritable => "the output couldn't be written: its folder is missing or read-only, the disk is full, or standard output closed",
Self::PathOutsideRoots => "laminapdf mcp was given a path outside its --root folders, or a link that leads out of them",
}
}
#[must_use]
pub const fn hint(self) -> &'static str {
match self {
Self::NotPdf => "check that the bytes passed to open are a PDF file",
Self::MissingRoot => "use another copy of the file: this one has no usable catalog",
Self::ReferenceCycle => "use another copy of the file, or repair it with another tool",
Self::LimitExceeded => "the input exceeds a safety limit; raise {limit} in Limits only if you trust the input",
Self::Strict => "open without strict mode to read the file with repairs, or fix the file",
Self::DataPending => "fetch the listed ranges into the source and retry the call",
Self::Source => "retry the call, or check the source; the document stays usable",
Self::Type => "use another copy of the file, or repair it with another tool",
Self::InvalidStructure => "use another copy of the file, or repair it with another tool",
Self::UnsetObject => "this is a bug in Lamina PDF: report it with the steps that led to it",
Self::RepairedBase => "save with a full rewrite instead of an incremental update",
Self::EncryptedBase => "save through Save::save with an entropy seed to keep the protection, or apply RemoveEncryption to drop it",
Self::PasswordRequired => "pass the document's password in OpenOptions",
Self::WrongPassword => "ask for the password again and retry with the correct one",
Self::UnsupportedSecurityHandler => "use a tool that supports this encryption to decrypt the file first",
Self::UnexpectedEof => "use a complete copy of the file: this one looks truncated",
Self::Syntax => "use another copy of the file, or repair it with another tool",
Self::UnsupportedFilter => "use a tool that supports the filter to read this stream",
Self::Decompress => "use another copy of the file: this stream's data is damaged",
Self::NestedTransaction => "commit or roll back the open transaction first, or use a savepoint inside it",
Self::NoTransaction => "call begin first, or use transact",
Self::UnknownPage => "use a PageId from this document's pages()",
Self::DirectPage => "rewrite the file so that every page is an indirect object, or wait for page-structure ops",
Self::UnsupportedVersion => "upgrade Lamina PDF to a version that reads this op log version",
Self::InvalidOpLog => "validate the op log against the op schema; the samples in fixtures/ops show the format",
Self::SavedNotRebased => "call rebase with the saved bytes before applying ops or saving again",
Self::NoPendingSave => "call rebase only after a save that returned SavedNotRebased",
Self::MalformedXmp => "set replaceMalformed on the edit to replace the packet with a new one, or leave the metadata as it is",
Self::UnknownSource => "add the source document's bytes with addSource before applying ops that name it",
Self::OpenActionNotDestination => "leave the open page out of the edit, which keeps the open action as it is",
Self::UnknownOutlineItem => "read the outline again and use one of its item IDs; an item a previous op deleted is gone",
Self::DirectOutlineItem => "apply any other outline op first: it rewrites the outline and gives every bookmark an object and an ID of its own",
Self::OutlineNotASibling => "name a position among the parent's own children, or use first or last",
Self::OutlineMoveIntoItself => "choose a parent outside the bookmark's own branch",
Self::UnknownNamedDestination => "list the file's named destinations and use one of their names",
Self::NamedDestinationExists => "choose a name no destination has, or delete the other one first",
Self::EmptyDestinationName => "give the destination a name of at least one character",
Self::LinkUriRefused => "use a full address such as https://example.com/page; encode other characters with %",
Self::ViewNotFinite => "pass finite numbers, or null to keep the viewer's current value",
Self::XmpClaimReadOnly => "leave the pdfaid: and pdfuaid: properties as they are; edit the other properties, or keep them unchanged in a replaced packet",
Self::InvalidXmpPacket => "fix the XML at the offset in the error's data (reason says what is wrong), then replace the packet again",
Self::InvalidXmpProperty => "check the part the error's reason names: the namespace, prefix, name, value, or the shape a mirrored property needs",
Self::NoPagesLeft => "keep at least one page: delete all but one, or insert a blank page first",
Self::InvalidOp => "insert between 1 and 10,000 pages at a time, each with a width and height above 0 and up to 14,400 points",
Self::UnknownAnnotation => "read the page's annotations again and use an ID from that list",
Self::AnnotationLocked => "clear the lock with an update of its flags first, if you may",
Self::AnnotationNotEditable => "edit a widget through its form field; an annotation stored inside the page's list can't be edited yet",
Self::NotALink => "name a link from the page's links; change other annotations with updateAnnot and deleteAnnot",
Self::LinkNotTagged => "tag the document first, or add the link to a copy that doesn't claim PDF/UA",
Self::AppearanceUnavailable => "edit through the laminapdf crate, which draws appearances, or give laminapdf-ops a generator with Document::with_appearances",
Self::AppearanceNeedsText => "in the extract module, use Helvetica, Times or Courier; otherwise open the document in the WebAssembly text module (pass text: true to init before opening it)",
Self::AnnotationGlyphMissing => "add a fallback font that has the character, or give the box a font that has it",
Self::AnnotationFontInvalid => "give the bytes of a TrueType or OpenType font whose licence allows embedding",
Self::StampImageInvalid => "add the bytes of a JPEG or PNG file and name that blob as the stamp's image",
Self::InvalidLabelRanges => "give ranges in page order, the first on the document's first page, each numbered from 1 or more",
Self::ContentObjectStale => "read the page's content objects again and name the object from that list",
Self::ContentNotEditable => "the content stays selectable and readable; the reason says why it can't be changed",
Self::UnknownBlob => "add the bytes with addBlob before applying ops that name them",
Self::ImagesUnavailable => "edit through the laminapdf crate, which writes images, or give laminapdf-ops a writer with Document::with_images",
Self::FlattenWidget => "leave widgets out of the annotations to flatten, and use flattenForm for form fields; a signature field is never flattened",
Self::UnknownAttachment => "read the attachments again and use an ID from that list: the attachment was deleted, or the ID comes from another document",
Self::AttachmentTooLarge => "attach a smaller file, or open the document with a higher maxStreamDecoded limit",
Self::UnknownField => "read the form's fields again and use an ID from that list: the field was removed, or the ID comes from another document",
Self::FieldIsSignature => "leave signature fields out of the values to set; sign the field instead",
Self::SignFieldSigned => "sign another signature field, or a new one; a field is signed once",
Self::SignCertifyNotFirst => "sign it without certify, or certify a copy that has no signature yet; a certification must be the first signature",
Self::FieldValueInvalid => "read the field's kind, options, on-states and maximum length, and give a value it accepts; the data field `reason` says which rule the value broke",
Self::FieldNameTaken => "give the field another name, or delete or rename the field that holds it",
Self::FieldNameInvalid => "name the field with parts that hold text, joined by single periods, and not below a field that has widgets",
Self::PdfaFieldActions => "leave the ResetForm action or the helper scripts off a file that claims PDF/A; a SubmitForm button is allowed",
Self::TabOrderNeedsStructure => "use row or column order, tag the document first, or remove the PDF/UA-1 claim; a file that claims PDF/UA-1 keeps structure order until the structure tree can be edited",
Self::TabOrderInvalid => "list each widget annotation of the page once, no more and no fewer, and none from another page",
Self::ContentIdInUse => "choose an ID no other added object on the page has, or update that object instead",
Self::UnknownContentObject => "read the page's added objects again and use an ID from that list",
Self::UnknownPageMark => "read the page's marks again and use an ID from that list",
Self::ContentObjectInvalid => "add the bytes of a JPEG or PNG file, or of a PDF and a page it has, and name that blob",
Self::ContentNeedsAltText => "give the image alternate text, or mark it as decoration so screen readers skip it",
Self::ContentGlyphMissing => "add a fallback font that has the character (a symbol font for symbols), or give the text a font that has it",
Self::ContentFontInvalid => "give the bytes of a TrueType or OpenType font, or one of helvetica, times and courier",
Self::ContentFontNotEmbeddable => "use a font whose licence allows embedding, such as one of the bundled fonts, or one of helvetica, times and courier",
Self::EncryptionNoPassword => "give a password that opens the file, a permissions password, or both",
Self::EncryptionPdfaConflict => "remove the PDF/A claim first, or keep the file unprotected",
Self::SecretMissing => "give the password again when you apply the operation",
Self::OwnerPasswordRequired => "ask for the file's permissions (owner) password and give it before changing the protection",
Self::NotEncrypted => "check whether the file is encrypted before offering to remove its protection",
Self::Sink => "check the destination and retry the save; the document is unchanged",
Self::NotRebased => "retry rebase with the saved output carried by the error",
Self::SinkNotEmpty => "pass an empty sink: output offsets count from the sink's first byte",
Self::WouldInvalidateSignatures => "save with SaveMode::Auto, or ask the user and retry with SaveOptions::with_invalidate_signatures",
Self::RequiresRewrite => "save with SaveMode::Auto or SaveMode::FullRewrite",
Self::EncryptionIncomplete => "report this as a bug with the file that triggers it; a file encrypted in part would leak its plain parts",
Self::EncryptionNoEntropy => "pass an entropy seed of 32 bytes from crypto.getRandomValues or getrandom when you save",
Self::SignPlaceholderTooSmall => "prepare the signature again with the reserve the error reports; nothing was written",
Self::SignKeyUnsupported => "use an X.509 certificate with an ECDSA P-256, ECDSA P-384 or RSA key, the signer's own first",
Self::SignSignerFailed => "try again, or check the signer: a cancelled PIN or a refusing card fails this way; give ECDSA values as DER or raw r and s, and RSA values as long as the modulus",
Self::SignDocumentChanged => "prepare the signature again after the last edit, and finish it on the same document before editing more",
Self::SignatureMalformed => "treat the signature as invalid and ask the signer for the original file: the report names the rule, such as a /ByteRange that does not leave out exactly the /Contents hex string",
Self::SignatureAlgorithmUnsupported => "validate the file with another tool, or ask the signer for a signature with SHA-256, SHA-384 or SHA-512 and RSA, ECDSA P-256, ECDSA P-384 or Ed25519",
Self::InvalidFont => "pass the complete bytes of a .ttf, .otf, .ttc or .otc file",
Self::CollectionIndex => "use an index below Font::collection_len",
Self::UnknownAxis => "check the font's axes before choosing coordinates, or use a variable font",
Self::FontNotEmbeddable => "use another font, or register it with EmbedPolicy::Override if your licence allows embedding",
Self::MissingGlyph => "use a font that covers the character, or split the text across fonts",
Self::GlyphOutOfRange => "pass glyph IDs from the font you registered",
Self::UnknownFont => "use the key returned by this registry's add",
Self::SubsetFailed => "try another version or format of the font, and report the font if it is a common one",
Self::InvalidAxisValue => "pass finite axis values; values outside the axis range are clamped",
Self::WrongDocument => "use one FontRegistry per document and finish it with that document",
Self::InvalidFeature => "write it as liga=0, -liga, smcp or aalt=2 (HarfBuzz syntax without ranges)",
Self::InvalidTextRange => "take ranges from Lamina PDF's results (line_breaks, itemize, break_lines) and pass the same text",
Self::InvalidSpans => "give spans in text order, each starting where the one before ends, from byte 0 to the end of the text, between grapheme clusters, each with at least one font from the list",
Self::UnsupportedLayoutOption => "leave the option at its default; justification comes with a later release",
Self::FontMismatch => "pass the key of the font the run was shaped with (the font index of each line run maps to your keys)",
Self::EncodingFull => "embed a font with Font::from_bytes, or split the text across two registrations of the standard font",
Self::FontNotShapable => "draw standard 14 fonts with FontRegistry::encode, or shape with an embedded font",
Self::InvalidImage => "pass the complete bytes of a JPEG or PNG file to Image::jpeg or Image::png",
Self::UnsupportedImage => "convert it to a baseline or progressive 8-bit JPEG, or to PNG",
Self::ImageTooLarge => "scale the image down before adding it",
Self::ImageDataLength => "pass exactly 4 bytes (RGBA) per pixel, row by row",
Self::InvalidIccProfile => "pass a complete ICC profile with a Gray, RGB or CMYK data colour space",
Self::ColorComponents => "give one component per channel of the colour space (/N of the ICC profile)",
Self::InvalidColor => "write the colour as # followed by 3 or 6 hexadecimal digits",
Self::InvalidGeometry => "use finite coordinates, positive page sizes and /UserUnit, non-negative line widths and dashes, a miter limit of at least 1, and images of at least one pixel",
Self::TextOverflow => "make the box taller or the text shorter, or use Overflow::Clip and read TextLayout::overflow",
Self::PageIndexOutOfRange => "use a 0-based index below the document's page count",
Self::UnknownDestination => "define it with Builder::destination before the build finishes, or link to a page",
Self::InvalidPageLabels => "give ranges sorted by first page, the first at page 0, numbered from 1",
Self::TagElementNotOpen => "resume and close only elements this builder's pages opened with open_element, and close each once",
Self::TagElementUnclosed => "close each element from open_element with Builder::close_element once its last page is finished",
Self::ProfileVersionConflict => "leave the version at 1.7 (the default) or lower; PDF 2.0 needs PDF/A-4 or PDF/UA-2, which Lamina PDF doesn't write yet",
Self::MissingTitle => "set a title with Builder::metadata (Metadata::with_title)",
Self::MissingLang => "set the language with Builder::lang, such as \"en-GB\"",
Self::MissingAltText => "give the figure or formula a description with Tag::with_alt or Surface::figure's alt, or draw decoration as an artifact",
Self::UntaggedContent => "draw it inside Surface::tag (real content) or Surface::artifact (decoration)",
Self::HeadingLevelSkipped => "start with H1 and go down one level at a time",
Self::UnnumberedHeadingMisused => "use numbered headings (H1, H2, ...) throughout, or one H per section",
Self::InvalidStructureNesting => "nest tables as Table > TR > TH/TD and lists as L > LI > Lbl/LBody",
Self::LinkWithoutStructure => "draw links outside artifacts, so the builder gives each one a Link element",
Self::LinkWithoutContents => "pass a description as the link's contents",
Self::FontNotEmbedded => "load a font file with Builder::font instead of Builder::standard_font",
Self::GlyphWithoutUnicode => "remove NUL characters (U+0000) from the text, or choose PDF/A-2b, which doesn't need Unicode",
Self::DeviceColorWithoutOutputIntent => "use RGB or gray colours, or a CMYK colour with an ICC profile (Color::icc)",
Self::EmbeddedFileForbidden => "choose PDF/A-3b, which allows attached files of any kind",
Self::EmbeddedFileWithoutMimeType => "pass the file's MIME type, such as text/xml or application/octet-stream",
Self::FlowContentTooLarge => "make the figure smaller, the text size smaller or the page's margins narrower",
Self::FlowLayoutUnstable => "report the flow that fails; a page break after the contents block may avoid it until it is fixed",
Self::InvalidDocument => "data.pointer names the value; correct it against the document schema, and didYouMean lists the closest known keys",
Self::TemplateDataMissing => "data.pointer names the value the template asked for; add it to the data or correct the pointer",
Self::TemplateDataType => "data.pointer names the value and data.expected the kind the template needs there",
Self::TemplateTooLarge => "data.limit is the limit it passed; repeat fewer items, or split the document",
Self::RenderTooLarge => "request smaller tiles (256 to 512 pixels at high zoom) or raise RenderLimits if the larger bitmap is intended",
Self::RenderFailed => "the file may be damaged or use a feature this engine can't draw; try the other backend, or report the file",
Self::RenderBackendUnavailable => "run cargo xtask fetch-pdfium or set LAMINA_PDF_PDFIUM_DIR to the folder holding the PDFium library",
Self::ExportFailed => "report it with the format and the page: the encoder writes into memory, so this is a bug in Lamina PDF",
Self::ModelFailed => "check the plug-in's own logs; extract without the model to get the rules-only result",
Self::ModelResultUnexpected => "call provide only while request() returns a request, with the result its kind asks for",
Self::ModelNeedsHost => "step an extraction job and hand it each result with provide, or give the plug-in a page renderer",
Self::InterchangeUnknownFormat => "pass an .xfdf or .fdf file exported from a PDF app, or form data JSON",
Self::InterchangeMalformed => "open the file in a text editor at that line, or export the comments again",
Self::InterchangeDtd => "export the comments again from the app that made the file; XFDF needs no DTD",
Self::SubmitPdfRefused => "export the form data and send that file instead",
Self::SubmitUrlRefused => "ask the form's sender for an https: address, or export the form data and send that file",
Self::InterchangeTooLarge => "raise Limits::max_stream_decoded if the file is expected to be this large",
Self::Cancelled => "nothing to do: this is the outcome the caller asked for; start a new job to try again",
Self::JobFinished => "stop stepping a job once a step returned its result or an error; create a new job",
Self::DocumentChanged => "pass the document the job was created from, and don't change it while the job runs; create a new job, or read the contents listing again",
Self::RevisionIndexOutOfRange => "ask for an index below the document's revision count",
Self::NoBookmarks => "add bookmarks that go to the document's pages first, then create the contents page",
Self::SoundUnavailable => "check the annotation's subtype and sound format in its record before asking for its samples",
Self::BuilderFinished => "create a new builder or page: a finished one takes no more drawing, pages, fonts or settings",
Self::Disposed => "free a handle only after its last use; to keep working, open the document again or create a new builder",
Self::InvalidArgument => "pass the value the type declarations describe; the data field says what was wrong",
Self::SourceBudgetExceeded => "raise the source's budget, or open the file with fewer bytes fetched (smaller blocks, no readahead)",
Self::UnknownOption => "remove the key or correct its spelling; didYouMean lists the closest known names",
Self::InvalidCommandLine => "run the command with --help to see its arguments",
Self::InvalidPageRange => "write pages as 1-5, z for the last page, r2 for the second from the end, or x3 to leave page 3 out; data.position is the character where the range went wrong",
Self::BinaryOutputToTerminal => "redirect standard output to a file or a pipe, or write to a file with -o",
Self::UnknownCode => "check the spelling against didYouMean, or list every code at the docs URL",
Self::OverwriteRefused => "pass --force, or write to a new file with -o",
Self::InputUnreadable => "check that the file exists and that you can read it; data.input names it",
Self::OutputUnwritable => "check that the output's folder exists, that you can write to it and that the disk has room",
Self::PathOutsideRoots => "use a path inside one of the server's --root folders, or start the server with another --root",
}
}
#[must_use]
pub fn docs_url(self) -> String {
format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WarningCode {
MissingHeader,
XrefRepaired,
XrefstmIgnored,
StreamLengthRecovered,
DictionaryKeySkipped,
StaleGeneration,
PageTreeNodeSkipped,
PageCountMismatch,
FlateTruncated,
FilterCharactersSkipped,
ObjstmIndexMismatch,
ObjectNumberOutOfRange,
AesPaddingInvalid,
PermsMismatch,
WarningsTruncated,
InvalidBox,
InvalidRotate,
NameTreeNodeSkipped,
OutlineCycle,
OutlineItemSkipped,
InvalidDate,
XmpInvalid,
AnnotNameDuplicate,
XmpRepaired,
InvalidPageLabel,
InvalidEntry,
ContentUnknownOperator,
ContentBadOperands,
ContentUnbalancedQ,
ContentUnbalancedBt,
ContentUnbalancedMarked,
ContentSyntax,
ContentResourceMissing,
InlineImageUnterminated,
XobjectCycle,
ContentPathUnpainted,
FontInvalid,
CmapInvalid,
UnmappedGlyph,
ExtractLimitBlocks,
ExtractReadingOrderAmbiguous,
ExtractTableAmbiguous,
ExtractTableLimit,
ExtractStructTreeIgnored,
ExtractUntaggedContent,
ExtractNeedsOcr,
ExtractColumnOrderUncertain,
PdfaOneAuthor,
PdfuaTitleMissing,
PdfaInfoMismatch,
DuplicateTagsIncomplete,
ImportedTagsDropped,
ImportedPdfaUnchecked,
ImportedPdfuaUnchecked,
AnnotWithoutContents,
AnnotNotTagged,
FieldLabelMissing,
PdfaAnnotFlags,
PdfaTransparency,
PdfaFontNotEmbedded,
FlattenUntagged,
FigureWithoutAlt,
ContentTagsBroken,
PdfaAttachmentForbidden,
PdfaAttachmentIncomplete,
PdfaColorSpace,
PdfaOptionalContent,
TounicodeConflict,
WholeFontRebuilt,
FlowKeepBroken,
MarkdownHtmlIgnored,
MarkdownImageMissing,
InterchangeSkipped,
InterchangeDocumentMismatch,
CoveredText,
RedactionNotApplied,
TextInEarlierRevision,
RichTextSimplified,
FlattenNoAppearance,
AttachmentStillHeld,
XfaRemoved,
FieldNameStillUsed,
FieldScriptReplaced,
SummaryPageNotDrawn,
}
impl WarningCode {
pub const ALL: &'static [Self] = &[
Self::MissingHeader,
Self::XrefRepaired,
Self::XrefstmIgnored,
Self::StreamLengthRecovered,
Self::DictionaryKeySkipped,
Self::StaleGeneration,
Self::PageTreeNodeSkipped,
Self::PageCountMismatch,
Self::FlateTruncated,
Self::FilterCharactersSkipped,
Self::ObjstmIndexMismatch,
Self::ObjectNumberOutOfRange,
Self::AesPaddingInvalid,
Self::PermsMismatch,
Self::WarningsTruncated,
Self::InvalidBox,
Self::InvalidRotate,
Self::NameTreeNodeSkipped,
Self::OutlineCycle,
Self::OutlineItemSkipped,
Self::InvalidDate,
Self::XmpInvalid,
Self::AnnotNameDuplicate,
Self::XmpRepaired,
Self::InvalidPageLabel,
Self::InvalidEntry,
Self::ContentUnknownOperator,
Self::ContentBadOperands,
Self::ContentUnbalancedQ,
Self::ContentUnbalancedBt,
Self::ContentUnbalancedMarked,
Self::ContentSyntax,
Self::ContentResourceMissing,
Self::InlineImageUnterminated,
Self::XobjectCycle,
Self::ContentPathUnpainted,
Self::FontInvalid,
Self::CmapInvalid,
Self::UnmappedGlyph,
Self::ExtractLimitBlocks,
Self::ExtractReadingOrderAmbiguous,
Self::ExtractTableAmbiguous,
Self::ExtractTableLimit,
Self::ExtractStructTreeIgnored,
Self::ExtractUntaggedContent,
Self::ExtractNeedsOcr,
Self::ExtractColumnOrderUncertain,
Self::PdfaOneAuthor,
Self::PdfuaTitleMissing,
Self::PdfaInfoMismatch,
Self::DuplicateTagsIncomplete,
Self::ImportedTagsDropped,
Self::ImportedPdfaUnchecked,
Self::ImportedPdfuaUnchecked,
Self::AnnotWithoutContents,
Self::AnnotNotTagged,
Self::FieldLabelMissing,
Self::PdfaAnnotFlags,
Self::PdfaTransparency,
Self::PdfaFontNotEmbedded,
Self::FlattenUntagged,
Self::FigureWithoutAlt,
Self::ContentTagsBroken,
Self::PdfaAttachmentForbidden,
Self::PdfaAttachmentIncomplete,
Self::PdfaColorSpace,
Self::PdfaOptionalContent,
Self::TounicodeConflict,
Self::WholeFontRebuilt,
Self::FlowKeepBroken,
Self::MarkdownHtmlIgnored,
Self::MarkdownImageMissing,
Self::InterchangeSkipped,
Self::InterchangeDocumentMismatch,
Self::CoveredText,
Self::RedactionNotApplied,
Self::TextInEarlierRevision,
Self::RichTextSimplified,
Self::FlattenNoAppearance,
Self::AttachmentStillHeld,
Self::XfaRemoved,
Self::FieldNameStillUsed,
Self::FieldScriptReplaced,
Self::SummaryPageNotDrawn,
];
#[must_use]
pub const fn from_code(code: &str) -> Option<Self> {
let mut rest = Self::ALL;
while let [first, tail @ ..] = rest {
if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
return Some(*first);
}
rest = tail;
}
None
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::MissingHeader => "missing-header",
Self::XrefRepaired => "xref-repaired",
Self::XrefstmIgnored => "xrefstm-ignored",
Self::StreamLengthRecovered => "stream-length-recovered",
Self::DictionaryKeySkipped => "dictionary-key-skipped",
Self::StaleGeneration => "stale-generation",
Self::PageTreeNodeSkipped => "page-tree-node-skipped",
Self::PageCountMismatch => "page-count-mismatch",
Self::FlateTruncated => "flate-truncated",
Self::FilterCharactersSkipped => "filter-characters-skipped",
Self::ObjstmIndexMismatch => "objstm-index-mismatch",
Self::ObjectNumberOutOfRange => "object-number-out-of-range",
Self::AesPaddingInvalid => "aes-padding-invalid",
Self::PermsMismatch => "perms-mismatch",
Self::WarningsTruncated => "warnings-truncated",
Self::InvalidBox => "invalid-box",
Self::InvalidRotate => "invalid-rotate",
Self::NameTreeNodeSkipped => "name-tree-node-skipped",
Self::OutlineCycle => "outline-cycle",
Self::OutlineItemSkipped => "outline-item-skipped",
Self::InvalidDate => "invalid-date",
Self::XmpInvalid => "xmp-invalid",
Self::AnnotNameDuplicate => "annot-name-duplicate",
Self::XmpRepaired => "xmp-repaired",
Self::InvalidPageLabel => "invalid-page-label",
Self::InvalidEntry => "invalid-entry",
Self::ContentUnknownOperator => "content-unknown-operator",
Self::ContentBadOperands => "content-bad-operands",
Self::ContentUnbalancedQ => "content-unbalanced-q",
Self::ContentUnbalancedBt => "content-unbalanced-bt",
Self::ContentUnbalancedMarked => "content-unbalanced-marked",
Self::ContentSyntax => "content-syntax",
Self::ContentResourceMissing => "content-resource-missing",
Self::InlineImageUnterminated => "inline-image-unterminated",
Self::XobjectCycle => "xobject-cycle",
Self::ContentPathUnpainted => "content-path-unpainted",
Self::FontInvalid => "font-invalid",
Self::CmapInvalid => "cmap-invalid",
Self::UnmappedGlyph => "unmapped-glyph",
Self::ExtractLimitBlocks => "extract-limit-blocks",
Self::ExtractReadingOrderAmbiguous => "extract-reading-order-ambiguous",
Self::ExtractTableAmbiguous => "extract-table-ambiguous",
Self::ExtractTableLimit => "extract-table-limit",
Self::ExtractStructTreeIgnored => "extract-struct-tree-ignored",
Self::ExtractUntaggedContent => "extract-untagged-content",
Self::ExtractNeedsOcr => "extract-needs-ocr",
Self::ExtractColumnOrderUncertain => "extract-column-order-uncertain",
Self::PdfaOneAuthor => "pdfa-one-author",
Self::PdfuaTitleMissing => "pdfua-title-missing",
Self::PdfaInfoMismatch => "pdfa-info-mismatch",
Self::DuplicateTagsIncomplete => "duplicate-tags-incomplete",
Self::ImportedTagsDropped => "imported-tags-dropped",
Self::ImportedPdfaUnchecked => "imported-pdfa-unchecked",
Self::ImportedPdfuaUnchecked => "imported-pdfua-unchecked",
Self::AnnotWithoutContents => "annot-without-contents",
Self::AnnotNotTagged => "annot-not-tagged",
Self::FieldLabelMissing => "field-label-missing",
Self::PdfaAnnotFlags => "pdfa-annot-flags",
Self::PdfaTransparency => "pdfa-transparency",
Self::PdfaFontNotEmbedded => "pdfa-font-not-embedded",
Self::FlattenUntagged => "flatten-untagged",
Self::FigureWithoutAlt => "figure-without-alt",
Self::ContentTagsBroken => "content-tags-broken",
Self::PdfaAttachmentForbidden => "pdfa-attachment-forbidden",
Self::PdfaAttachmentIncomplete => "pdfa-attachment-incomplete",
Self::PdfaColorSpace => "pdfa-color-space",
Self::PdfaOptionalContent => "pdfa-optional-content",
Self::TounicodeConflict => "tounicode-conflict",
Self::WholeFontRebuilt => "whole-font-rebuilt",
Self::FlowKeepBroken => "flow-keep-broken",
Self::MarkdownHtmlIgnored => "markdown-html-ignored",
Self::MarkdownImageMissing => "markdown-image-missing",
Self::InterchangeSkipped => "interchange-skipped",
Self::InterchangeDocumentMismatch => "interchange-document-mismatch",
Self::CoveredText => "covered-text",
Self::RedactionNotApplied => "redaction-not-applied",
Self::TextInEarlierRevision => "text-in-earlier-revision",
Self::RichTextSimplified => "rich-text-simplified",
Self::FlattenNoAppearance => "flatten-no-appearance",
Self::AttachmentStillHeld => "attachment-still-held",
Self::XfaRemoved => "xfa-removed",
Self::FieldNameStillUsed => "field-name-still-used",
Self::FieldScriptReplaced => "field-script-replaced",
Self::SummaryPageNotDrawn => "summary-page-not-drawn",
}
}
#[must_use]
pub const fn kind(self) -> ErrorKind {
match self {
Self::MissingHeader => ErrorKind::Input,
Self::XrefRepaired => ErrorKind::Input,
Self::XrefstmIgnored => ErrorKind::Input,
Self::StreamLengthRecovered => ErrorKind::Input,
Self::DictionaryKeySkipped => ErrorKind::Input,
Self::StaleGeneration => ErrorKind::Input,
Self::PageTreeNodeSkipped => ErrorKind::Input,
Self::PageCountMismatch => ErrorKind::Input,
Self::FlateTruncated => ErrorKind::Input,
Self::FilterCharactersSkipped => ErrorKind::Input,
Self::ObjstmIndexMismatch => ErrorKind::Input,
Self::ObjectNumberOutOfRange => ErrorKind::Limit,
Self::AesPaddingInvalid => ErrorKind::Security,
Self::PermsMismatch => ErrorKind::Security,
Self::WarningsTruncated => ErrorKind::Limit,
Self::InvalidBox => ErrorKind::Input,
Self::InvalidRotate => ErrorKind::Input,
Self::NameTreeNodeSkipped => ErrorKind::Input,
Self::OutlineCycle => ErrorKind::Input,
Self::OutlineItemSkipped => ErrorKind::Input,
Self::InvalidDate => ErrorKind::Input,
Self::XmpInvalid => ErrorKind::Input,
Self::AnnotNameDuplicate => ErrorKind::Input,
Self::XmpRepaired => ErrorKind::Input,
Self::InvalidPageLabel => ErrorKind::Input,
Self::InvalidEntry => ErrorKind::Input,
Self::ContentUnknownOperator => ErrorKind::Input,
Self::ContentBadOperands => ErrorKind::Input,
Self::ContentUnbalancedQ => ErrorKind::Input,
Self::ContentUnbalancedBt => ErrorKind::Input,
Self::ContentUnbalancedMarked => ErrorKind::Input,
Self::ContentSyntax => ErrorKind::Input,
Self::ContentResourceMissing => ErrorKind::Input,
Self::InlineImageUnterminated => ErrorKind::Input,
Self::XobjectCycle => ErrorKind::Input,
Self::ContentPathUnpainted => ErrorKind::Input,
Self::FontInvalid => ErrorKind::Input,
Self::CmapInvalid => ErrorKind::Input,
Self::UnmappedGlyph => ErrorKind::Input,
Self::ExtractLimitBlocks => ErrorKind::Limit,
Self::ExtractReadingOrderAmbiguous => ErrorKind::Unsupported,
Self::ExtractTableAmbiguous => ErrorKind::Unsupported,
Self::ExtractTableLimit => ErrorKind::Limit,
Self::ExtractStructTreeIgnored => ErrorKind::Input,
Self::ExtractUntaggedContent => ErrorKind::Input,
Self::ExtractNeedsOcr => ErrorKind::Unsupported,
Self::ExtractColumnOrderUncertain => ErrorKind::Unsupported,
Self::PdfaOneAuthor => ErrorKind::Usage,
Self::PdfuaTitleMissing => ErrorKind::Usage,
Self::PdfaInfoMismatch => ErrorKind::Input,
Self::DuplicateTagsIncomplete => ErrorKind::Usage,
Self::ImportedTagsDropped => ErrorKind::Usage,
Self::ImportedPdfaUnchecked => ErrorKind::Usage,
Self::ImportedPdfuaUnchecked => ErrorKind::Usage,
Self::AnnotWithoutContents => ErrorKind::Usage,
Self::AnnotNotTagged => ErrorKind::Usage,
Self::FieldLabelMissing => ErrorKind::Usage,
Self::PdfaAnnotFlags => ErrorKind::Usage,
Self::PdfaTransparency => ErrorKind::Usage,
Self::PdfaFontNotEmbedded => ErrorKind::Usage,
Self::FlattenUntagged => ErrorKind::Usage,
Self::FigureWithoutAlt => ErrorKind::Usage,
Self::ContentTagsBroken => ErrorKind::Input,
Self::PdfaAttachmentForbidden => ErrorKind::Usage,
Self::PdfaAttachmentIncomplete => ErrorKind::Usage,
Self::PdfaColorSpace => ErrorKind::Usage,
Self::PdfaOptionalContent => ErrorKind::Usage,
Self::TounicodeConflict => ErrorKind::Usage,
Self::WholeFontRebuilt => ErrorKind::Usage,
Self::FlowKeepBroken => ErrorKind::Usage,
Self::MarkdownHtmlIgnored => ErrorKind::Unsupported,
Self::MarkdownImageMissing => ErrorKind::Usage,
Self::InterchangeSkipped => ErrorKind::Unsupported,
Self::InterchangeDocumentMismatch => ErrorKind::Input,
Self::CoveredText => ErrorKind::Security,
Self::RedactionNotApplied => ErrorKind::Security,
Self::TextInEarlierRevision => ErrorKind::Security,
Self::RichTextSimplified => ErrorKind::Usage,
Self::FlattenNoAppearance => ErrorKind::Unsupported,
Self::AttachmentStillHeld => ErrorKind::Usage,
Self::XfaRemoved => ErrorKind::Unsupported,
Self::FieldNameStillUsed => ErrorKind::Usage,
Self::FieldScriptReplaced => ErrorKind::Usage,
Self::SummaryPageNotDrawn => ErrorKind::Unsupported,
}
}
#[must_use]
pub const fn summary(self) -> &'static str {
match self {
Self::MissingHeader => "no %PDF-x.y header in the first 1,024 bytes; parsing went ahead",
Self::XrefRepaired => "the stored cross-reference data was unusable and was rebuilt by scanning",
Self::XrefstmIgnored => "a hybrid file's /XRefStm could not be read and was ignored",
Self::StreamLengthRecovered => "a stream's /Length was wrong, so its end was found by scanning for endstream",
Self::DictionaryKeySkipped => "a dictionary had something other than a name where a key belongs, and it was skipped",
Self::StaleGeneration => "a reference's generation did not match its xref entry, so it resolved to null",
Self::PageTreeNodeSkipped => "a page-tree node was missing, malformed or too deep, and was skipped",
Self::PageCountMismatch => "the page tree's /Count differs from the number of pages walked",
Self::FlateTruncated => "Flate data was truncated or had a bad checksum; the partial output was kept",
Self::FilterCharactersSkipped => "ASCIIHex or ASCII85 data held characters outside the filter's alphabet; they were skipped",
Self::ObjstmIndexMismatch => "an object stream's index was stale and the object was found by searching",
Self::ObjectNumberOutOfRange => "an xref entry above max_object_number was dropped",
Self::AesPaddingInvalid => "AES-encrypted data had a bad length or padding and was kept as stored",
Self::PermsMismatch => "an R5/R6 document's /Perms does not match its /P and /EncryptMetadata",
Self::WarningsTruncated => "more than max_warnings warnings were raised and the rest were dropped",
Self::InvalidBox => "a page boundary box is not four numbers and reads as absent",
Self::InvalidRotate => "a page's /Rotate is not a multiple of 90 and reads as 0",
Self::NameTreeNodeSkipped => "a name- or number-tree node was malformed, repeated or too deep, and was skipped",
Self::OutlineCycle => "an outline item was reached twice; that branch of the walk stopped",
Self::OutlineItemSkipped => "an outline item was missing, not a dictionary or too deep, and was skipped with its subtree",
Self::InvalidDate => "an Info date is not a valid PDF date; the raw string is kept",
Self::XmpInvalid => "the XMP metadata packet is not readable XMP and reads as absent",
Self::AnnotNameDuplicate => "two annotations on one page have the same name (/NM), which should be unique on its page",
Self::XmpRepaired => "the XMP metadata packet had damage other readers read past, and was read the same way",
Self::InvalidPageLabel => "a /PageLabels entry is malformed; the malformed part is dropped",
Self::InvalidEntry => "an entry a view reads is unreadable or of the wrong type and reads as absent",
Self::ContentUnknownOperator => "an operator the spec does not define was skipped outside a BX/EX section",
Self::ContentBadOperands => "an operator had too few operands or operands of the wrong type, or extra ones",
Self::ContentUnbalancedQ => "a Q without a matching q was ignored, or saved graphics states were left open",
Self::ContentUnbalancedBt => "a text object was opened twice, closed outside one, or left open",
Self::ContentUnbalancedMarked => "an EMC without a matching BMC or BDC was ignored, or marked content was left open",
Self::ContentSyntax => "content-stream bytes that are not a token were skipped",
Self::ContentResourceMissing => "an operator named a resource that is missing, of the wrong type or unreadable",
Self::InlineImageUnterminated => "no EI ends an inline image; the rest of the content was skipped",
Self::XobjectCycle => "a Form XObject draws itself, directly or through other forms",
Self::ContentPathUnpainted => "a content stream ended with a path no painting operator ended",
Self::FontInvalid => "a font dictionary has a missing or malformed entry, so its text was decoded with defaults",
Self::CmapInvalid => "a font's CMap or ToUnicode CMap is malformed or names a predefined CMap Lamina PDF has no table for",
Self::UnmappedGlyph => "a font shows glyphs that nothing maps to text",
Self::ExtractLimitBlocks => "a page had more runs of text than the extraction block limit; the runs past it were left out",
Self::ExtractReadingOrderAmbiguous => "a page mixes horizontal and vertical writing, so the order of its blocks is a guess",
Self::ExtractTableAmbiguous => "a table's rules marked out merged cells that aren't rectangles, so its cells were kept unmerged",
Self::ExtractTableLimit => "a page's ruling lines would make a table bigger than the extraction's cell limit; those lines gave no table",
Self::ExtractStructTreeIgnored => "a tagged page's structure tree covered too little of its text, or its order jumped back across columns too often, so the layout gave the reading order",
Self::ExtractUntaggedContent => "a page read in structure-tree order has visible text that is neither in the tree nor an artifact; it follows the tree's blocks, in layout order",
Self::ExtractNeedsOcr => "a page has no usable text layer: it is an image (with or without an invisible OCR layer), outlined glyphs, or glyphs without Unicode, so its extracted text is empty or unreliable",
Self::ExtractColumnOrderUncertain => "the layout rules had to guess how a page's columns are read, so its blocks may be in the wrong order; the blocks concerned have a lower confidence",
Self::PdfaOneAuthor => "the file claims PDF/A-1, which allows one author, and its metadata lists more",
Self::PdfuaTitleMissing => "the file claims PDF/UA-1, which requires a title in its metadata, and it has none",
Self::PdfaInfoMismatch => "the file claims PDF/A, which requires the Info dictionary and the XMP packet to agree, and they differ",
Self::DuplicateTagsIncomplete => "a duplicated page's content is partly untagged, which breaks the PDF/UA claim of the document's metadata",
Self::ImportedTagsDropped => "pages copied in from another document came without their tags, which breaks the PDF/UA claim of the document's metadata",
Self::ImportedPdfaUnchecked => "pages copied in from a document that doesn't claim the same PDF/A level may break the PDF/A claim of the document's metadata",
Self::ImportedPdfuaUnchecked => "pages copied in from a document that doesn't claim PDF/UA-1 may break the PDF/UA claim of the document's metadata",
Self::AnnotWithoutContents => "a new or changed annotation has no description, which breaks the document's PDF/UA claim",
Self::AnnotNotTagged => "a new annotation isn't in the structure tree, which breaks the document's PDF/UA claim",
Self::FieldLabelMissing => "a new form field has no label for screen readers, which breaks the document's PDF/UA claim",
Self::PdfaAnnotFlags => "an annotation doesn't print or is hidden, which breaks the document's PDF/A claim",
Self::PdfaTransparency => "an annotation, or an object added to a page, is translucent or blends, or is an image with an alpha channel, which PDF/A-1 forbids",
Self::PdfaFontNotEmbedded => "the file claims PDF/A, and an edited annotation or page uses a font that isn't embedded, such as a text box in a standard 14 font",
Self::FlattenUntagged => "the file claims PDF/UA-1, and flattening took comments or form fields out of the structure tree: their text is no longer read out",
Self::FigureWithoutAlt => "the file claims PDF/UA, and an edit replaced a figure's image: the figure's alternative text described the old image and was removed",
Self::ContentTagsBroken => "the file claims PDF/UA, and edited pages draw content their tags don't cover, often because the file's tags were already incomplete",
Self::PdfaAttachmentForbidden => "the file claims PDF/A-1 or PDF/A-2, which allow no attached files but PDF/A ones, and the edits attached a file",
Self::PdfaAttachmentIncomplete => "the file claims PDF/A-3, and an attached file lacks an association with the document, a page or an annotation, a modification date or a MIME type",
Self::PdfaColorSpace => "the file claims PDF/A, and something the edits added paints in a device colour space its output intent doesn't allow, such as a CMYK photo in a file with an RGB intent",
Self::PdfaOptionalContent => "the file claims PDF/A-1, and a watermark or background the edits added is in an optional content group, which PDF/A-1 forbids",
Self::TounicodeConflict => "one glyph was used for two different texts; ToUnicode keeps the first",
Self::WholeFontRebuilt => "a font that forbids subsetting was rebuilt with every glyph kept",
Self::FlowKeepBroken => "blocks kept together are taller than a page, so the flow split them",
Self::MarkdownHtmlIgnored => "the Markdown holds raw HTML, which the PDF leaves out",
Self::MarkdownImageMissing => "the Markdown names an image that wasn't supplied, so the PDF leaves it out",
Self::InterchangeSkipped => "the import leaves out a comment or field it can't make: a sound, a link, a form field's value, a comment for a page the document doesn't have, or a reply to a missing comment",
Self::InterchangeDocumentMismatch => "the exchange file was made for another PDF (its /ID or file name differs), so its comments may land in the wrong places",
Self::CoveredText => "a page draws text and then paints a shape, an image or an annotation over it, so the text is hidden but still in the file",
Self::RedactionNotApplied => "a page has redaction marks that were never applied, so the text under them is still in the file",
Self::TextInEarlierRevision => "an earlier revision of the file holds text that the latest revision no longer has",
Self::RichTextSimplified => "an edit changed a text box whose rich text had styles Lamina PDF doesn't keep, such as a size or colour per word, so the box now has one size and colour",
Self::FlattenNoAppearance => "flattening left some annotations in place: they have no appearance, and Lamina PDF can't draw one for their kind",
Self::AttachmentStillHeld => "a deleted attachment stays in the document because a file attachment annotation still holds it",
Self::XfaRemoved => "flattening removed the form's XFA part, so apps that read XFA forms show the fields that are left as a plain PDF form",
Self::FieldNameStillUsed => "a deleted or renamed form field's name, or a split field's object, is still used: a button's or a signed field's lock list names it, or a calculation reads it; or a list names a group the renamed field left",
Self::FieldScriptReplaced => "a field's format, validation or calculation script that isn't one of Acrobat's helper calls was replaced by the helper call written",
Self::SummaryPageNotDrawn => "a comment summary lists a page's comments without drawing the page, because the page uses a font the file doesn't embed, which PDF/UA-1 forbids, has content Lamina PDF can't read to its end, or belongs to a protected file whose open password forbids copying",
}
}
#[must_use]
pub const fn hint(self) -> &'static str {
match self {
Self::MissingHeader => "nothing to do if the document reads correctly; open in strict mode to refuse such files",
Self::XrefRepaired => "check the result; save with a full rewrite, since an incremental update refuses a repaired base",
Self::XrefstmIgnored => "nothing to do; the classic xref table is used instead",
Self::StreamLengthRecovered => "nothing to do; a full rewrite writes the correct length",
Self::DictionaryKeySkipped => "nothing to do if the document reads correctly; open in strict mode to refuse such files",
Self::StaleGeneration => "nothing to do; the reference is treated as missing",
Self::PageTreeNodeSkipped => "check the page count: pages under the skipped node are missing",
Self::PageCountMismatch => "nothing to do; Lamina PDF uses the walked page count",
Self::FlateTruncated => "check the affected content: the end of the stream may be missing",
Self::FilterCharactersSkipped => "check the affected content: the stream is damaged, and what decoded may differ from what was written",
Self::ObjstmIndexMismatch => "nothing to do; a full rewrite writes a correct index",
Self::ObjectNumberOutOfRange => "raise max_object_number in Limits only if you trust the input",
Self::AesPaddingInvalid => "treat the affected strings and streams as suspect: they may have been tampered with",
Self::PermsMismatch => "treat the document's permissions as untrusted",
Self::WarningsTruncated => "raise max_warnings in Limits if you need the full list",
Self::InvalidBox => "nothing to do; the page uses the next box in the fallback chain",
Self::InvalidRotate => "set the page rotation explicitly if 0 is wrong",
Self::NameTreeNodeSkipped => "check the tree's entries: those under the skipped node are missing",
Self::OutlineCycle => "nothing to do; the outline is read without the loop",
Self::OutlineItemSkipped => "check the outline: the skipped item and its children are missing",
Self::InvalidDate => "read the raw value from the Info view if you need it",
Self::XmpInvalid => "nothing to do; a metadata edit asks before replacing it",
Self::AnnotNameDuplicate => "nothing to do; both are kept, and annotations are told apart by their own IDs",
Self::XmpRepaired => "nothing to do; a metadata edit writes the declarations the packet left out",
Self::InvalidPageLabel => "nothing to do; affected pages fall back to decimal labels",
Self::InvalidEntry => "nothing to do; the view uses the entry's default",
Self::ContentUnknownOperator => "nothing to do; check the page's rendering if the operator mattered",
Self::ContentBadOperands => "nothing to do; the operator was skipped or used its last operands",
Self::ContentUnbalancedQ => "nothing to do; the graphics state was restored as the spec intends",
Self::ContentUnbalancedBt => "nothing to do; text operators outside a text object were handled tolerantly",
Self::ContentUnbalancedMarked => "check tagged-content results: marked-content sequences were closed for you",
Self::ContentSyntax => "check the page's content: the bytes around the reported offset were skipped",
Self::ContentResourceMissing => "check the page's resources: the operator ran without the resource or was skipped",
Self::InlineImageUnterminated => "check the page's content: everything after the inline image is missing",
Self::XobjectCycle => "nothing to do; the inner Do was skipped",
Self::ContentPathUnpainted => "nothing to do; the unpainted path was dropped as the spec intends",
Self::FontInvalid => "nothing to do; extracted text or positions for that font may be off",
Self::CmapInvalid => "nothing to do; the bad entries were skipped and the rest of the CMap is used",
Self::UnmappedGlyph => "nothing to do; those glyphs extract as U+FFFD (the file needs a ToUnicode CMap)",
Self::ExtractLimitBlocks => "raise ExtractLimits::max_blocks_per_page if the page really has that many blocks",
Self::ExtractReadingOrderAmbiguous => "nothing to do; check the order of that page's blocks, or ask for content order",
Self::ExtractTableAmbiguous => "nothing to do; check that table's cells, whose text may be split across neighbours",
Self::ExtractTableLimit => "raise ExtractLimits::max_table_cells if the page really has a table that big",
Self::ExtractStructTreeIgnored => "nothing to do; ReadingOrder::Tagged uses the tree anyway",
Self::ExtractUntaggedContent => "nothing to do; tag that text in the file to give it a place in the reading order",
Self::ExtractNeedsOcr => "run OCR or a vision model on this page; the page's textLayer in the JSON says which case it is",
Self::ExtractColumnOrderUncertain => "check the page, or send it to a layout model; the warning's reason says which guess was made",
Self::PdfaOneAuthor => "keep one author (join the names into one), or save knowing the file no longer meets PDF/A-1",
Self::PdfuaTitleMissing => "give the document a title before saving, or save knowing the file no longer meets PDF/UA-1",
Self::PdfaInfoMismatch => "edit the metadata with setMetadata, which writes both, or remove the Info entries that differ",
Self::DuplicateTagsIncomplete => "retag the copy, or duplicate pages whose tagged elements lie on the page alone",
Self::ImportedTagsDropped => "tag the copied pages in a tagging tool, or copy pages from a document without tags",
Self::ImportedPdfaUnchecked => "check the saved file with a PDF/A validator such as veraPDF, or copy pages from a document that claims the same level",
Self::ImportedPdfuaUnchecked => "check the saved file's tags, alternate text and reading order with a PDF/UA checker such as veraPDF, or copy pages from a document that claims PDF/UA-1",
Self::AnnotWithoutContents => "give the annotation a description: the text it marks, or what the mark means",
Self::AnnotNotTagged => "tag the document first, or add the annotation to a copy that doesn't claim PDF/UA",
Self::FieldLabelMissing => "give the field a tooltip: the name a screen reader says",
Self::PdfaAnnotFlags => "keep the annotation's Print flag and clear Hidden, Invisible, NoView and ToggleNoView",
Self::PdfaTransparency => "make the mark or object opaque, use an image without transparency, or use an underline instead of a highlight",
Self::PdfaFontNotEmbedded => "give a text box a font by its bytes (add them with addBlob), which Lamina PDF embeds as a subset; before flattening, embed the font in the annotation's appearance with the app that made it, or flatten a copy",
Self::FlattenUntagged => "save knowing the file no longer meets PDF/UA-1, or keep the comments and fields as they are and flatten a copy",
Self::FigureWithoutAlt => "undo the image replacement, or add alternative text with an accessibility tool and open the file again; or save without the PDF/UA claim (removeConformanceClaims)",
Self::ContentTagsBroken => "undo the edit, or save without the PDF/UA claim (removeConformanceClaims) and tag the page again with an accessibility tool",
Self::PdfaAttachmentForbidden => "attach the file to a copy saved without the PDF/A claim, or save knowing the file may no longer meet its PDF/A level",
Self::PdfaAttachmentIncomplete => "attach the file to the document, a page or an annotation, with its modification date and MIME type",
Self::PdfaColorSpace => "convert the image to the output intent's colour space (RGB for an RGB intent, CMYK for a CMYK intent), or give it an ICC profile, before you add it; or save without the PDF/A claim (removeConformanceClaims)",
Self::PdfaOptionalContent => "add the mark without hideable, or save without the PDF/A claim (removeConformanceClaims)",
Self::TounicodeConflict => "mark the second occurrence with /ActualText so extraction gets its text",
Self::WholeFontRebuilt => "check that the font's licence allows this, or use a static TrueType or CFF version",
Self::FlowKeepBroken => "split the keep group or drop keep-with-next on a heading chain, or use a taller page",
Self::MarkdownHtmlIgnored => "write the content in Markdown instead of HTML, or remove the HTML",
Self::MarkdownImageMissing => "pass the image's bytes with MarkdownBuildOptions::with_image under the path the Markdown uses",
Self::InterchangeSkipped => "nothing to do: the rest of the file is imported; form data is imported with the form tools",
Self::InterchangeDocumentMismatch => "check that the file belongs to this document before importing it",
Self::CoveredText => "remove the text itself with a tool that deletes what a redaction covers, then save a full rewrite",
Self::RedactionNotApplied => "apply the redactions in a tool that removes what they cover, then save a full rewrite",
Self::TextInEarlierRevision => "save the file as a full rewrite, which keeps only the latest revision",
Self::RichTextSimplified => "check how the box looks; bold and italic are kept, and the box's own font, size, colour and alignment apply to all of its text",
Self::FlattenNoAppearance => "nothing to do if they should stay; otherwise give them an appearance in the app that made them, or delete them",
Self::AttachmentStillHeld => "delete the annotation too to take the file out of the document",
Self::XfaRemoved => "nothing to do: the flattened answers are on the page, and the fields left stay fillable as a plain PDF form; anything only the XFA part did is gone",
Self::FieldNameStillUsed => "change the list or the calculation that still names the field or the group",
Self::FieldScriptReplaced => "nothing to do if the helper call is what you meant; undo the change to keep the script",
Self::SummaryPageNotDrawn => "nothing to do if the list is enough; to see the page beside its comments, embed its fonts first, for example by printing the document to PDF again, or give a protected file's permissions password, then make the summary again",
}
}
#[must_use]
pub fn docs_url(self) -> String {
format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
}
}