1#![allow(
6 clippy::too_many_lines,
7 clippy::match_same_arms,
8 clippy::doc_markdown,
9 reason = "generated: one match arm per code; summaries are codes.json text"
10)]
11
12use crate::ErrorKind;
13
14pub const DOCS_URL_BASE: &str = "https://docs.laminapdf.com/reference/codes/";
18
19pub const DOCS_URL_SUFFIX: &str = "/";
23
24const fn bytes_eq(a: &[u8], b: &[u8]) -> bool {
26 if a.len() != b.len() {
27 return false;
28 }
29 let (mut a, mut b) = (a, b);
30 while let ([x, a_rest @ ..], [y, b_rest @ ..]) = (a, b) {
31 if *x != *y {
32 return false;
33 }
34 a = a_rest;
35 b = b_rest;
36 }
37 true
38}
39
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
45#[non_exhaustive]
46pub enum ErrorCode {
47 NotPdf,
49 MissingRoot,
51 ReferenceCycle,
53 LimitExceeded,
55 Strict,
57 DataPending,
59 Source,
61 Type,
63 InvalidStructure,
65 UnsetObject,
67 RepairedBase,
69 EncryptedBase,
71 PasswordRequired,
73 WrongPassword,
75 UnsupportedSecurityHandler,
77 UnexpectedEof,
79 Syntax,
81 UnsupportedFilter,
83 Decompress,
85 NestedTransaction,
87 NoTransaction,
89 UnknownPage,
91 DirectPage,
93 UnsupportedVersion,
95 InvalidOpLog,
97 SavedNotRebased,
99 NoPendingSave,
101 MalformedXmp,
103 UnknownSource,
105 OpenActionNotDestination,
107 UnknownOutlineItem,
109 DirectOutlineItem,
111 OutlineNotASibling,
113 OutlineMoveIntoItself,
115 UnknownNamedDestination,
117 NamedDestinationExists,
119 EmptyDestinationName,
121 LinkUriRefused,
123 ViewNotFinite,
125 XmpClaimReadOnly,
127 InvalidXmpPacket,
129 InvalidXmpProperty,
131 NoPagesLeft,
133 InvalidOp,
135 UnknownAnnotation,
137 AnnotationLocked,
139 AnnotationNotEditable,
141 NotALink,
143 LinkNotTagged,
145 AppearanceUnavailable,
147 AppearanceNeedsText,
149 AnnotationGlyphMissing,
151 AnnotationFontInvalid,
153 StampImageInvalid,
155 InvalidLabelRanges,
157 ContentObjectStale,
159 ContentNotEditable,
161 UnknownBlob,
163 ImagesUnavailable,
165 FlattenWidget,
167 UnknownAttachment,
169 AttachmentTooLarge,
171 UnknownField,
173 FieldIsSignature,
175 SignFieldSigned,
177 SignCertifyNotFirst,
179 FieldValueInvalid,
181 FieldNameTaken,
183 FieldNameInvalid,
185 PdfaFieldActions,
187 TabOrderNeedsStructure,
189 TabOrderInvalid,
191 ContentIdInUse,
193 UnknownContentObject,
195 UnknownPageMark,
197 ContentObjectInvalid,
199 ContentNeedsAltText,
201 ContentGlyphMissing,
203 ContentFontInvalid,
205 ContentFontNotEmbeddable,
207 EncryptionNoPassword,
209 EncryptionPdfaConflict,
211 SecretMissing,
213 OwnerPasswordRequired,
215 NotEncrypted,
217 SanitiseIncomplete,
219 SanitiseLimit,
221 RedactionMarkMissing,
223 RedactionIncomplete,
225 Sink,
227 NotRebased,
229 SinkNotEmpty,
231 WouldInvalidateSignatures,
233 RequiresRewrite,
235 EncryptionIncomplete,
237 EncryptionNoEntropy,
239 SignPlaceholderTooSmall,
241 SignKeyUnsupported,
243 SignSignerFailed,
245 SignDocumentChanged,
247 SignatureMalformed,
249 SignatureAlgorithmUnsupported,
251 InvalidFont,
253 CollectionIndex,
255 UnknownAxis,
257 FontNotEmbeddable,
259 MissingGlyph,
261 GlyphOutOfRange,
263 UnknownFont,
265 SubsetFailed,
267 InvalidAxisValue,
269 WrongDocument,
271 InvalidFeature,
273 InvalidTextRange,
275 InvalidSpans,
277 UnsupportedLayoutOption,
279 FontMismatch,
281 EncodingFull,
283 FontNotShapable,
285 InvalidImage,
287 UnsupportedImage,
289 ImageTooLarge,
291 ImageDataLength,
293 InvalidIccProfile,
295 ColorComponents,
297 InvalidColor,
299 InvalidGeometry,
301 TextOverflow,
303 PageIndexOutOfRange,
305 UnknownDestination,
307 InvalidPageLabels,
309 TagElementNotOpen,
311 TagElementUnclosed,
313 ProfileVersionConflict,
315 MissingTitle,
317 MissingLang,
319 MissingAltText,
321 UntaggedContent,
323 HeadingLevelSkipped,
325 UnnumberedHeadingMisused,
327 InvalidStructureNesting,
329 LinkWithoutStructure,
331 LinkWithoutContents,
333 FontNotEmbedded,
335 GlyphWithoutUnicode,
337 DeviceColorWithoutOutputIntent,
339 EmbeddedFileForbidden,
341 EmbeddedFileWithoutMimeType,
343 FlowContentTooLarge,
345 FlowLayoutUnstable,
347 InvalidDocument,
349 TemplateDataMissing,
351 TemplateDataType,
353 TemplateTooLarge,
355 RenderTooLarge,
357 RenderFailed,
359 RenderBackendUnavailable,
361 ExportFailed,
363 ModelFailed,
365 ModelResultUnexpected,
367 ModelNeedsHost,
369 InterchangeUnknownFormat,
371 InterchangeMalformed,
373 InterchangeDtd,
375 SubmitPdfRefused,
377 SubmitUrlRefused,
379 InterchangeTooLarge,
381 Cancelled,
383 JobFinished,
385 DocumentChanged,
387 RevisionIndexOutOfRange,
389 NoBookmarks,
391 SoundUnavailable,
393 BuilderFinished,
395 Disposed,
397 InvalidArgument,
399 SourceBudgetExceeded,
401 UnknownOption,
403 InvalidCommandLine,
405 InvalidPageRange,
407 BinaryOutputToTerminal,
409 UnknownCode,
411 OverwriteRefused,
413 InputUnreadable,
415 OutputUnwritable,
417 PathOutsideRoots,
419}
420
421impl ErrorCode {
422 pub const ALL: &'static [Self] = &[
426 Self::NotPdf,
427 Self::MissingRoot,
428 Self::ReferenceCycle,
429 Self::LimitExceeded,
430 Self::Strict,
431 Self::DataPending,
432 Self::Source,
433 Self::Type,
434 Self::InvalidStructure,
435 Self::UnsetObject,
436 Self::RepairedBase,
437 Self::EncryptedBase,
438 Self::PasswordRequired,
439 Self::WrongPassword,
440 Self::UnsupportedSecurityHandler,
441 Self::UnexpectedEof,
442 Self::Syntax,
443 Self::UnsupportedFilter,
444 Self::Decompress,
445 Self::NestedTransaction,
446 Self::NoTransaction,
447 Self::UnknownPage,
448 Self::DirectPage,
449 Self::UnsupportedVersion,
450 Self::InvalidOpLog,
451 Self::SavedNotRebased,
452 Self::NoPendingSave,
453 Self::MalformedXmp,
454 Self::UnknownSource,
455 Self::OpenActionNotDestination,
456 Self::UnknownOutlineItem,
457 Self::DirectOutlineItem,
458 Self::OutlineNotASibling,
459 Self::OutlineMoveIntoItself,
460 Self::UnknownNamedDestination,
461 Self::NamedDestinationExists,
462 Self::EmptyDestinationName,
463 Self::LinkUriRefused,
464 Self::ViewNotFinite,
465 Self::XmpClaimReadOnly,
466 Self::InvalidXmpPacket,
467 Self::InvalidXmpProperty,
468 Self::NoPagesLeft,
469 Self::InvalidOp,
470 Self::UnknownAnnotation,
471 Self::AnnotationLocked,
472 Self::AnnotationNotEditable,
473 Self::NotALink,
474 Self::LinkNotTagged,
475 Self::AppearanceUnavailable,
476 Self::AppearanceNeedsText,
477 Self::AnnotationGlyphMissing,
478 Self::AnnotationFontInvalid,
479 Self::StampImageInvalid,
480 Self::InvalidLabelRanges,
481 Self::ContentObjectStale,
482 Self::ContentNotEditable,
483 Self::UnknownBlob,
484 Self::ImagesUnavailable,
485 Self::FlattenWidget,
486 Self::UnknownAttachment,
487 Self::AttachmentTooLarge,
488 Self::UnknownField,
489 Self::FieldIsSignature,
490 Self::SignFieldSigned,
491 Self::SignCertifyNotFirst,
492 Self::FieldValueInvalid,
493 Self::FieldNameTaken,
494 Self::FieldNameInvalid,
495 Self::PdfaFieldActions,
496 Self::TabOrderNeedsStructure,
497 Self::TabOrderInvalid,
498 Self::ContentIdInUse,
499 Self::UnknownContentObject,
500 Self::UnknownPageMark,
501 Self::ContentObjectInvalid,
502 Self::ContentNeedsAltText,
503 Self::ContentGlyphMissing,
504 Self::ContentFontInvalid,
505 Self::ContentFontNotEmbeddable,
506 Self::EncryptionNoPassword,
507 Self::EncryptionPdfaConflict,
508 Self::SecretMissing,
509 Self::OwnerPasswordRequired,
510 Self::NotEncrypted,
511 Self::SanitiseIncomplete,
512 Self::SanitiseLimit,
513 Self::RedactionMarkMissing,
514 Self::RedactionIncomplete,
515 Self::Sink,
516 Self::NotRebased,
517 Self::SinkNotEmpty,
518 Self::WouldInvalidateSignatures,
519 Self::RequiresRewrite,
520 Self::EncryptionIncomplete,
521 Self::EncryptionNoEntropy,
522 Self::SignPlaceholderTooSmall,
523 Self::SignKeyUnsupported,
524 Self::SignSignerFailed,
525 Self::SignDocumentChanged,
526 Self::SignatureMalformed,
527 Self::SignatureAlgorithmUnsupported,
528 Self::InvalidFont,
529 Self::CollectionIndex,
530 Self::UnknownAxis,
531 Self::FontNotEmbeddable,
532 Self::MissingGlyph,
533 Self::GlyphOutOfRange,
534 Self::UnknownFont,
535 Self::SubsetFailed,
536 Self::InvalidAxisValue,
537 Self::WrongDocument,
538 Self::InvalidFeature,
539 Self::InvalidTextRange,
540 Self::InvalidSpans,
541 Self::UnsupportedLayoutOption,
542 Self::FontMismatch,
543 Self::EncodingFull,
544 Self::FontNotShapable,
545 Self::InvalidImage,
546 Self::UnsupportedImage,
547 Self::ImageTooLarge,
548 Self::ImageDataLength,
549 Self::InvalidIccProfile,
550 Self::ColorComponents,
551 Self::InvalidColor,
552 Self::InvalidGeometry,
553 Self::TextOverflow,
554 Self::PageIndexOutOfRange,
555 Self::UnknownDestination,
556 Self::InvalidPageLabels,
557 Self::TagElementNotOpen,
558 Self::TagElementUnclosed,
559 Self::ProfileVersionConflict,
560 Self::MissingTitle,
561 Self::MissingLang,
562 Self::MissingAltText,
563 Self::UntaggedContent,
564 Self::HeadingLevelSkipped,
565 Self::UnnumberedHeadingMisused,
566 Self::InvalidStructureNesting,
567 Self::LinkWithoutStructure,
568 Self::LinkWithoutContents,
569 Self::FontNotEmbedded,
570 Self::GlyphWithoutUnicode,
571 Self::DeviceColorWithoutOutputIntent,
572 Self::EmbeddedFileForbidden,
573 Self::EmbeddedFileWithoutMimeType,
574 Self::FlowContentTooLarge,
575 Self::FlowLayoutUnstable,
576 Self::InvalidDocument,
577 Self::TemplateDataMissing,
578 Self::TemplateDataType,
579 Self::TemplateTooLarge,
580 Self::RenderTooLarge,
581 Self::RenderFailed,
582 Self::RenderBackendUnavailable,
583 Self::ExportFailed,
584 Self::ModelFailed,
585 Self::ModelResultUnexpected,
586 Self::ModelNeedsHost,
587 Self::InterchangeUnknownFormat,
588 Self::InterchangeMalformed,
589 Self::InterchangeDtd,
590 Self::SubmitPdfRefused,
591 Self::SubmitUrlRefused,
592 Self::InterchangeTooLarge,
593 Self::Cancelled,
594 Self::JobFinished,
595 Self::DocumentChanged,
596 Self::RevisionIndexOutOfRange,
597 Self::NoBookmarks,
598 Self::SoundUnavailable,
599 Self::BuilderFinished,
600 Self::Disposed,
601 Self::InvalidArgument,
602 Self::SourceBudgetExceeded,
603 Self::UnknownOption,
604 Self::InvalidCommandLine,
605 Self::InvalidPageRange,
606 Self::BinaryOutputToTerminal,
607 Self::UnknownCode,
608 Self::OverwriteRefused,
609 Self::InputUnreadable,
610 Self::OutputUnwritable,
611 Self::PathOutsideRoots,
612 ];
613
614 #[must_use]
618 pub const fn from_code(code: &str) -> Option<Self> {
619 let mut rest = Self::ALL;
620 while let [first, tail @ ..] = rest {
621 if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
622 return Some(*first);
623 }
624 rest = tail;
625 }
626 None
627 }
628
629 #[must_use]
633 pub const fn as_str(self) -> &'static str {
634 match self {
635 Self::NotPdf => "not-pdf",
636 Self::MissingRoot => "missing-root",
637 Self::ReferenceCycle => "reference-cycle",
638 Self::LimitExceeded => "limit-exceeded",
639 Self::Strict => "strict",
640 Self::DataPending => "data-pending",
641 Self::Source => "source",
642 Self::Type => "type",
643 Self::InvalidStructure => "invalid-structure",
644 Self::UnsetObject => "unset-object",
645 Self::RepairedBase => "repaired-base",
646 Self::EncryptedBase => "encrypted-base",
647 Self::PasswordRequired => "password-required",
648 Self::WrongPassword => "wrong-password",
649 Self::UnsupportedSecurityHandler => "unsupported-security-handler",
650 Self::UnexpectedEof => "unexpected-eof",
651 Self::Syntax => "syntax",
652 Self::UnsupportedFilter => "unsupported-filter",
653 Self::Decompress => "decompress",
654 Self::NestedTransaction => "nested-transaction",
655 Self::NoTransaction => "no-transaction",
656 Self::UnknownPage => "unknown-page",
657 Self::DirectPage => "direct-page",
658 Self::UnsupportedVersion => "unsupported-version",
659 Self::InvalidOpLog => "invalid-op-log",
660 Self::SavedNotRebased => "saved-not-rebased",
661 Self::NoPendingSave => "no-pending-save",
662 Self::MalformedXmp => "malformed-xmp",
663 Self::UnknownSource => "unknown-source",
664 Self::OpenActionNotDestination => "open-action-not-destination",
665 Self::UnknownOutlineItem => "unknown-outline-item",
666 Self::DirectOutlineItem => "direct-outline-item",
667 Self::OutlineNotASibling => "outline-not-a-sibling",
668 Self::OutlineMoveIntoItself => "outline-move-into-itself",
669 Self::UnknownNamedDestination => "unknown-named-destination",
670 Self::NamedDestinationExists => "named-destination-exists",
671 Self::EmptyDestinationName => "empty-destination-name",
672 Self::LinkUriRefused => "link-uri-refused",
673 Self::ViewNotFinite => "view-not-finite",
674 Self::XmpClaimReadOnly => "xmp-claim-read-only",
675 Self::InvalidXmpPacket => "invalid-xmp-packet",
676 Self::InvalidXmpProperty => "invalid-xmp-property",
677 Self::NoPagesLeft => "no-pages-left",
678 Self::InvalidOp => "invalid-op",
679 Self::UnknownAnnotation => "unknown-annotation",
680 Self::AnnotationLocked => "annotation-locked",
681 Self::AnnotationNotEditable => "annotation-not-editable",
682 Self::NotALink => "not-a-link",
683 Self::LinkNotTagged => "link-not-tagged",
684 Self::AppearanceUnavailable => "appearance-unavailable",
685 Self::AppearanceNeedsText => "appearance-needs-text",
686 Self::AnnotationGlyphMissing => "annotation-glyph-missing",
687 Self::AnnotationFontInvalid => "annotation-font-invalid",
688 Self::StampImageInvalid => "stamp-image-invalid",
689 Self::InvalidLabelRanges => "invalid-label-ranges",
690 Self::ContentObjectStale => "content-object-stale",
691 Self::ContentNotEditable => "content-not-editable",
692 Self::UnknownBlob => "unknown-blob",
693 Self::ImagesUnavailable => "images-unavailable",
694 Self::FlattenWidget => "flatten-widget",
695 Self::UnknownAttachment => "unknown-attachment",
696 Self::AttachmentTooLarge => "attachment-too-large",
697 Self::UnknownField => "unknown-field",
698 Self::FieldIsSignature => "field-is-signature",
699 Self::SignFieldSigned => "sign-field-signed",
700 Self::SignCertifyNotFirst => "sign-certify-not-first",
701 Self::FieldValueInvalid => "field-value-invalid",
702 Self::FieldNameTaken => "field-name-taken",
703 Self::FieldNameInvalid => "field-name-invalid",
704 Self::PdfaFieldActions => "pdfa-field-actions",
705 Self::TabOrderNeedsStructure => "tab-order-needs-structure",
706 Self::TabOrderInvalid => "tab-order-invalid",
707 Self::ContentIdInUse => "content-id-in-use",
708 Self::UnknownContentObject => "unknown-content-object",
709 Self::UnknownPageMark => "unknown-page-mark",
710 Self::ContentObjectInvalid => "content-object-invalid",
711 Self::ContentNeedsAltText => "content-needs-alt-text",
712 Self::ContentGlyphMissing => "content-glyph-missing",
713 Self::ContentFontInvalid => "content-font-invalid",
714 Self::ContentFontNotEmbeddable => "content-font-not-embeddable",
715 Self::EncryptionNoPassword => "encryption-no-password",
716 Self::EncryptionPdfaConflict => "encryption-pdfa-conflict",
717 Self::SecretMissing => "secret-missing",
718 Self::OwnerPasswordRequired => "owner-password-required",
719 Self::NotEncrypted => "not-encrypted",
720 Self::SanitiseIncomplete => "sanitise-incomplete",
721 Self::SanitiseLimit => "sanitise-limit",
722 Self::RedactionMarkMissing => "redaction-mark-missing",
723 Self::RedactionIncomplete => "redaction-incomplete",
724 Self::Sink => "sink",
725 Self::NotRebased => "not-rebased",
726 Self::SinkNotEmpty => "sink-not-empty",
727 Self::WouldInvalidateSignatures => "would-invalidate-signatures",
728 Self::RequiresRewrite => "requires-rewrite",
729 Self::EncryptionIncomplete => "encryption-incomplete",
730 Self::EncryptionNoEntropy => "encryption-no-entropy",
731 Self::SignPlaceholderTooSmall => "sign-placeholder-too-small",
732 Self::SignKeyUnsupported => "sign-key-unsupported",
733 Self::SignSignerFailed => "sign-signer-failed",
734 Self::SignDocumentChanged => "sign-document-changed",
735 Self::SignatureMalformed => "signature-malformed",
736 Self::SignatureAlgorithmUnsupported => "signature-algorithm-unsupported",
737 Self::InvalidFont => "invalid-font",
738 Self::CollectionIndex => "collection-index",
739 Self::UnknownAxis => "unknown-axis",
740 Self::FontNotEmbeddable => "font-not-embeddable",
741 Self::MissingGlyph => "missing-glyph",
742 Self::GlyphOutOfRange => "glyph-out-of-range",
743 Self::UnknownFont => "unknown-font",
744 Self::SubsetFailed => "subset-failed",
745 Self::InvalidAxisValue => "invalid-axis-value",
746 Self::WrongDocument => "wrong-document",
747 Self::InvalidFeature => "invalid-feature",
748 Self::InvalidTextRange => "invalid-text-range",
749 Self::InvalidSpans => "invalid-spans",
750 Self::UnsupportedLayoutOption => "unsupported-layout-option",
751 Self::FontMismatch => "font-mismatch",
752 Self::EncodingFull => "encoding-full",
753 Self::FontNotShapable => "font-not-shapable",
754 Self::InvalidImage => "invalid-image",
755 Self::UnsupportedImage => "unsupported-image",
756 Self::ImageTooLarge => "image-too-large",
757 Self::ImageDataLength => "image-data-length",
758 Self::InvalidIccProfile => "invalid-icc-profile",
759 Self::ColorComponents => "color-components",
760 Self::InvalidColor => "invalid-color",
761 Self::InvalidGeometry => "invalid-geometry",
762 Self::TextOverflow => "text-overflow",
763 Self::PageIndexOutOfRange => "page-index-out-of-range",
764 Self::UnknownDestination => "unknown-destination",
765 Self::InvalidPageLabels => "invalid-page-labels",
766 Self::TagElementNotOpen => "tag-element-not-open",
767 Self::TagElementUnclosed => "tag-element-unclosed",
768 Self::ProfileVersionConflict => "profile-version-conflict",
769 Self::MissingTitle => "missing-title",
770 Self::MissingLang => "missing-lang",
771 Self::MissingAltText => "missing-alt-text",
772 Self::UntaggedContent => "untagged-content",
773 Self::HeadingLevelSkipped => "heading-level-skipped",
774 Self::UnnumberedHeadingMisused => "unnumbered-heading-misused",
775 Self::InvalidStructureNesting => "invalid-structure-nesting",
776 Self::LinkWithoutStructure => "link-without-structure",
777 Self::LinkWithoutContents => "link-without-contents",
778 Self::FontNotEmbedded => "font-not-embedded",
779 Self::GlyphWithoutUnicode => "glyph-without-unicode",
780 Self::DeviceColorWithoutOutputIntent => "device-color-without-output-intent",
781 Self::EmbeddedFileForbidden => "embedded-file-forbidden",
782 Self::EmbeddedFileWithoutMimeType => "embedded-file-without-mime-type",
783 Self::FlowContentTooLarge => "flow-content-too-large",
784 Self::FlowLayoutUnstable => "flow-layout-unstable",
785 Self::InvalidDocument => "invalid-document",
786 Self::TemplateDataMissing => "template-data-missing",
787 Self::TemplateDataType => "template-data-type",
788 Self::TemplateTooLarge => "template-too-large",
789 Self::RenderTooLarge => "render-too-large",
790 Self::RenderFailed => "render-failed",
791 Self::RenderBackendUnavailable => "render-backend-unavailable",
792 Self::ExportFailed => "export-failed",
793 Self::ModelFailed => "model-failed",
794 Self::ModelResultUnexpected => "model-result-unexpected",
795 Self::ModelNeedsHost => "model-needs-host",
796 Self::InterchangeUnknownFormat => "interchange-unknown-format",
797 Self::InterchangeMalformed => "interchange-malformed",
798 Self::InterchangeDtd => "interchange-dtd",
799 Self::SubmitPdfRefused => "submit-pdf-refused",
800 Self::SubmitUrlRefused => "submit-url-refused",
801 Self::InterchangeTooLarge => "interchange-too-large",
802 Self::Cancelled => "cancelled",
803 Self::JobFinished => "job-finished",
804 Self::DocumentChanged => "document-changed",
805 Self::RevisionIndexOutOfRange => "revision-index-out-of-range",
806 Self::NoBookmarks => "no-bookmarks",
807 Self::SoundUnavailable => "sound-unavailable",
808 Self::BuilderFinished => "builder-finished",
809 Self::Disposed => "disposed",
810 Self::InvalidArgument => "invalid-argument",
811 Self::SourceBudgetExceeded => "source-budget-exceeded",
812 Self::UnknownOption => "unknown-option",
813 Self::InvalidCommandLine => "invalid-command-line",
814 Self::InvalidPageRange => "invalid-page-range",
815 Self::BinaryOutputToTerminal => "binary-output-to-terminal",
816 Self::UnknownCode => "unknown-code",
817 Self::OverwriteRefused => "overwrite-refused",
818 Self::InputUnreadable => "input-unreadable",
819 Self::OutputUnwritable => "output-unwritable",
820 Self::PathOutsideRoots => "path-outside-roots",
821 }
822 }
823
824 #[must_use]
828 pub const fn kind(self) -> ErrorKind {
829 match self {
830 Self::NotPdf => ErrorKind::Input,
831 Self::MissingRoot => ErrorKind::Input,
832 Self::ReferenceCycle => ErrorKind::Input,
833 Self::LimitExceeded => ErrorKind::Limit,
834 Self::Strict => ErrorKind::Input,
835 Self::DataPending => ErrorKind::State,
836 Self::Source => ErrorKind::Io,
837 Self::Type => ErrorKind::Input,
838 Self::InvalidStructure => ErrorKind::Input,
839 Self::UnsetObject => ErrorKind::Internal,
840 Self::RepairedBase => ErrorKind::State,
841 Self::EncryptedBase => ErrorKind::Unsupported,
842 Self::PasswordRequired => ErrorKind::Security,
843 Self::WrongPassword => ErrorKind::Security,
844 Self::UnsupportedSecurityHandler => ErrorKind::Unsupported,
845 Self::UnexpectedEof => ErrorKind::Input,
846 Self::Syntax => ErrorKind::Input,
847 Self::UnsupportedFilter => ErrorKind::Unsupported,
848 Self::Decompress => ErrorKind::Input,
849 Self::NestedTransaction => ErrorKind::State,
850 Self::NoTransaction => ErrorKind::State,
851 Self::UnknownPage => ErrorKind::Usage,
852 Self::DirectPage => ErrorKind::Unsupported,
853 Self::UnsupportedVersion => ErrorKind::Unsupported,
854 Self::InvalidOpLog => ErrorKind::Input,
855 Self::SavedNotRebased => ErrorKind::State,
856 Self::NoPendingSave => ErrorKind::State,
857 Self::MalformedXmp => ErrorKind::Input,
858 Self::UnknownSource => ErrorKind::Usage,
859 Self::OpenActionNotDestination => ErrorKind::Usage,
860 Self::UnknownOutlineItem => ErrorKind::Usage,
861 Self::DirectOutlineItem => ErrorKind::Unsupported,
862 Self::OutlineNotASibling => ErrorKind::Usage,
863 Self::OutlineMoveIntoItself => ErrorKind::Usage,
864 Self::UnknownNamedDestination => ErrorKind::Usage,
865 Self::NamedDestinationExists => ErrorKind::Usage,
866 Self::EmptyDestinationName => ErrorKind::Usage,
867 Self::LinkUriRefused => ErrorKind::Usage,
868 Self::ViewNotFinite => ErrorKind::Usage,
869 Self::XmpClaimReadOnly => ErrorKind::Usage,
870 Self::InvalidXmpPacket => ErrorKind::Input,
871 Self::InvalidXmpProperty => ErrorKind::Usage,
872 Self::NoPagesLeft => ErrorKind::Usage,
873 Self::InvalidOp => ErrorKind::Usage,
874 Self::UnknownAnnotation => ErrorKind::Usage,
875 Self::AnnotationLocked => ErrorKind::State,
876 Self::AnnotationNotEditable => ErrorKind::Unsupported,
877 Self::NotALink => ErrorKind::Usage,
878 Self::LinkNotTagged => ErrorKind::Unsupported,
879 Self::AppearanceUnavailable => ErrorKind::Unsupported,
880 Self::AppearanceNeedsText => ErrorKind::Unsupported,
881 Self::AnnotationGlyphMissing => ErrorKind::Usage,
882 Self::AnnotationFontInvalid => ErrorKind::Usage,
883 Self::StampImageInvalid => ErrorKind::Usage,
884 Self::InvalidLabelRanges => ErrorKind::Usage,
885 Self::ContentObjectStale => ErrorKind::State,
886 Self::ContentNotEditable => ErrorKind::Unsupported,
887 Self::UnknownBlob => ErrorKind::Usage,
888 Self::ImagesUnavailable => ErrorKind::Unsupported,
889 Self::FlattenWidget => ErrorKind::Usage,
890 Self::UnknownAttachment => ErrorKind::Usage,
891 Self::AttachmentTooLarge => ErrorKind::Limit,
892 Self::UnknownField => ErrorKind::Usage,
893 Self::FieldIsSignature => ErrorKind::Usage,
894 Self::SignFieldSigned => ErrorKind::Usage,
895 Self::SignCertifyNotFirst => ErrorKind::Usage,
896 Self::FieldValueInvalid => ErrorKind::Usage,
897 Self::FieldNameTaken => ErrorKind::Usage,
898 Self::FieldNameInvalid => ErrorKind::Usage,
899 Self::PdfaFieldActions => ErrorKind::Usage,
900 Self::TabOrderNeedsStructure => ErrorKind::Usage,
901 Self::TabOrderInvalid => ErrorKind::Usage,
902 Self::ContentIdInUse => ErrorKind::Usage,
903 Self::UnknownContentObject => ErrorKind::Usage,
904 Self::UnknownPageMark => ErrorKind::Usage,
905 Self::ContentObjectInvalid => ErrorKind::Usage,
906 Self::ContentNeedsAltText => ErrorKind::Usage,
907 Self::ContentGlyphMissing => ErrorKind::Usage,
908 Self::ContentFontInvalid => ErrorKind::Usage,
909 Self::ContentFontNotEmbeddable => ErrorKind::Usage,
910 Self::EncryptionNoPassword => ErrorKind::Usage,
911 Self::EncryptionPdfaConflict => ErrorKind::State,
912 Self::SecretMissing => ErrorKind::Usage,
913 Self::OwnerPasswordRequired => ErrorKind::Security,
914 Self::NotEncrypted => ErrorKind::State,
915 Self::SanitiseIncomplete => ErrorKind::Internal,
916 Self::SanitiseLimit => ErrorKind::Limit,
917 Self::RedactionMarkMissing => ErrorKind::Usage,
918 Self::RedactionIncomplete => ErrorKind::Unsupported,
919 Self::Sink => ErrorKind::Io,
920 Self::NotRebased => ErrorKind::State,
921 Self::SinkNotEmpty => ErrorKind::Usage,
922 Self::WouldInvalidateSignatures => ErrorKind::Security,
923 Self::RequiresRewrite => ErrorKind::State,
924 Self::EncryptionIncomplete => ErrorKind::Security,
925 Self::EncryptionNoEntropy => ErrorKind::Usage,
926 Self::SignPlaceholderTooSmall => ErrorKind::Limit,
927 Self::SignKeyUnsupported => ErrorKind::Unsupported,
928 Self::SignSignerFailed => ErrorKind::Io,
929 Self::SignDocumentChanged => ErrorKind::State,
930 Self::SignatureMalformed => ErrorKind::Security,
931 Self::SignatureAlgorithmUnsupported => ErrorKind::Unsupported,
932 Self::InvalidFont => ErrorKind::Input,
933 Self::CollectionIndex => ErrorKind::Usage,
934 Self::UnknownAxis => ErrorKind::Usage,
935 Self::FontNotEmbeddable => ErrorKind::Usage,
936 Self::MissingGlyph => ErrorKind::Input,
937 Self::GlyphOutOfRange => ErrorKind::Usage,
938 Self::UnknownFont => ErrorKind::Usage,
939 Self::SubsetFailed => ErrorKind::Unsupported,
940 Self::InvalidAxisValue => ErrorKind::Usage,
941 Self::WrongDocument => ErrorKind::Usage,
942 Self::InvalidFeature => ErrorKind::Usage,
943 Self::InvalidTextRange => ErrorKind::Usage,
944 Self::InvalidSpans => ErrorKind::Usage,
945 Self::UnsupportedLayoutOption => ErrorKind::Unsupported,
946 Self::FontMismatch => ErrorKind::Usage,
947 Self::EncodingFull => ErrorKind::Limit,
948 Self::FontNotShapable => ErrorKind::Unsupported,
949 Self::InvalidImage => ErrorKind::Input,
950 Self::UnsupportedImage => ErrorKind::Unsupported,
951 Self::ImageTooLarge => ErrorKind::Limit,
952 Self::ImageDataLength => ErrorKind::Usage,
953 Self::InvalidIccProfile => ErrorKind::Input,
954 Self::ColorComponents => ErrorKind::Usage,
955 Self::InvalidColor => ErrorKind::Usage,
956 Self::InvalidGeometry => ErrorKind::Usage,
957 Self::TextOverflow => ErrorKind::Usage,
958 Self::PageIndexOutOfRange => ErrorKind::Usage,
959 Self::UnknownDestination => ErrorKind::Usage,
960 Self::InvalidPageLabels => ErrorKind::Usage,
961 Self::TagElementNotOpen => ErrorKind::Usage,
962 Self::TagElementUnclosed => ErrorKind::Usage,
963 Self::ProfileVersionConflict => ErrorKind::Usage,
964 Self::MissingTitle => ErrorKind::Usage,
965 Self::MissingLang => ErrorKind::Usage,
966 Self::MissingAltText => ErrorKind::Usage,
967 Self::UntaggedContent => ErrorKind::Usage,
968 Self::HeadingLevelSkipped => ErrorKind::Usage,
969 Self::UnnumberedHeadingMisused => ErrorKind::Usage,
970 Self::InvalidStructureNesting => ErrorKind::Usage,
971 Self::LinkWithoutStructure => ErrorKind::Usage,
972 Self::LinkWithoutContents => ErrorKind::Usage,
973 Self::FontNotEmbedded => ErrorKind::Usage,
974 Self::GlyphWithoutUnicode => ErrorKind::Usage,
975 Self::DeviceColorWithoutOutputIntent => ErrorKind::Usage,
976 Self::EmbeddedFileForbidden => ErrorKind::Usage,
977 Self::EmbeddedFileWithoutMimeType => ErrorKind::Usage,
978 Self::FlowContentTooLarge => ErrorKind::Usage,
979 Self::FlowLayoutUnstable => ErrorKind::Internal,
980 Self::InvalidDocument => ErrorKind::Usage,
981 Self::TemplateDataMissing => ErrorKind::Usage,
982 Self::TemplateDataType => ErrorKind::Usage,
983 Self::TemplateTooLarge => ErrorKind::Usage,
984 Self::RenderTooLarge => ErrorKind::Limit,
985 Self::RenderFailed => ErrorKind::Input,
986 Self::RenderBackendUnavailable => ErrorKind::Io,
987 Self::ExportFailed => ErrorKind::Internal,
988 Self::ModelFailed => ErrorKind::Internal,
989 Self::ModelResultUnexpected => ErrorKind::Usage,
990 Self::ModelNeedsHost => ErrorKind::Usage,
991 Self::InterchangeUnknownFormat => ErrorKind::Input,
992 Self::InterchangeMalformed => ErrorKind::Input,
993 Self::InterchangeDtd => ErrorKind::Security,
994 Self::SubmitPdfRefused => ErrorKind::Security,
995 Self::SubmitUrlRefused => ErrorKind::Security,
996 Self::InterchangeTooLarge => ErrorKind::Limit,
997 Self::Cancelled => ErrorKind::Cancelled,
998 Self::JobFinished => ErrorKind::State,
999 Self::DocumentChanged => ErrorKind::State,
1000 Self::RevisionIndexOutOfRange => ErrorKind::Usage,
1001 Self::NoBookmarks => ErrorKind::Usage,
1002 Self::SoundUnavailable => ErrorKind::Usage,
1003 Self::BuilderFinished => ErrorKind::State,
1004 Self::Disposed => ErrorKind::State,
1005 Self::InvalidArgument => ErrorKind::Usage,
1006 Self::SourceBudgetExceeded => ErrorKind::Limit,
1007 Self::UnknownOption => ErrorKind::Usage,
1008 Self::InvalidCommandLine => ErrorKind::Usage,
1009 Self::InvalidPageRange => ErrorKind::Usage,
1010 Self::BinaryOutputToTerminal => ErrorKind::Usage,
1011 Self::UnknownCode => ErrorKind::Usage,
1012 Self::OverwriteRefused => ErrorKind::State,
1013 Self::InputUnreadable => ErrorKind::Io,
1014 Self::OutputUnwritable => ErrorKind::Io,
1015 Self::PathOutsideRoots => ErrorKind::Security,
1016 }
1017 }
1018
1019 #[must_use]
1023 pub const fn summary(self) -> &'static str {
1024 match self {
1025 Self::NotPdf => "the input does not look like a PDF at all",
1026 Self::MissingRoot => "no document catalog (/Root) was found, even after repair",
1027 Self::ReferenceCycle => "a reference chain or the page tree loops back on itself",
1028 Self::LimitExceeded => "a hard Limits value was exceeded",
1029 Self::Strict => "strict mode refused something the tolerant reader would have repaired",
1030 Self::DataPending => "the ByteSource has not fetched the byte ranges the call needs yet",
1031 Self::Source => "the ByteSource failed to read",
1032 Self::Type => "an object had a different type than the structure requires",
1033 Self::InvalidStructure => "an object stream, xref section or filter parameter was malformed",
1034 Self::UnsetObject => "a writer object number was reserved but never given a value",
1035 Self::RepairedBase => "an incremental update was requested for a document whose xref needed repair",
1036 Self::EncryptedBase => "a save of an encrypted document was requested",
1037 Self::PasswordRequired => "the document is encrypted with a user password and none was given",
1038 Self::WrongPassword => "the given password is neither the user nor the owner password",
1039 Self::UnsupportedSecurityHandler => "the document uses a security handler Lamina PDF cannot decrypt",
1040 Self::UnexpectedEof => "the input ended before a complete token or object was read",
1041 Self::Syntax => "a token or structure did not match the PDF grammar",
1042 Self::UnsupportedFilter => "a stream uses a filter Lamina PDF does not implement",
1043 Self::Decompress => "compressed stream data was corrupt",
1044 Self::NestedTransaction => "a transaction was started, or undo or redo called, while one is open",
1045 Self::NoTransaction => "apply, commit or rollback was called without an open transaction",
1046 Self::UnknownPage => "an op names a page the document does not have",
1047 Self::DirectPage => "the page is a direct dictionary, which ops cannot edit yet",
1048 Self::UnsupportedVersion => "an op log has a schema version this reader does not know",
1049 Self::InvalidOpLog => "an op log does not parse: an unknown op or field, a bad value, or not JSON",
1050 Self::SavedNotRebased => "the document was saved to a sink Lamina PDF cannot read back and waits for rebase",
1051 Self::NoPendingSave => "rebase was called without a save waiting for it",
1052 Self::MalformedXmp => "a metadata edit would replace the document's XMP packet, which can't be read, losing what it holds",
1053 Self::UnknownSource => "an op or a call names a source document that was not added to the session",
1054 Self::OpenActionNotDestination => "an op would replace or remove the document's open action, which is an action other than a destination",
1055 Self::UnknownOutlineItem => "an outline op names a bookmark the outline does not have",
1056 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",
1057 Self::OutlineNotASibling => "the position names a bookmark that is not a child of the parent the op names",
1058 Self::OutlineMoveIntoItself => "a move would put a bookmark inside itself or one of its descendants",
1059 Self::UnknownNamedDestination => "the op names a destination the file does not define",
1060 Self::NamedDestinationExists => "a rename to a name another destination already has",
1061 Self::EmptyDestinationName => "a destination name is empty",
1062 Self::LinkUriRefused => "a web address that isn't an absolute http, https or mailto address in plain ASCII",
1063 Self::ViewNotFinite => "a destination's coordinates and zoom must be finite numbers",
1064 Self::XmpClaimReadOnly => "an XMP edit would change the file's PDF/A or PDF/UA identification, which only conversion or a check may set",
1065 Self::InvalidXmpPacket => "the XMP packet given to replace the document's doesn't parse",
1066 Self::InvalidXmpProperty => "an XMP property edit names a property, or gives a value, that can't be written",
1067 Self::NoPagesLeft => "a page deletion would leave the document with no pages",
1068 Self::InvalidOp => "an op's values are out of range, such as a page count or a page size",
1069 Self::UnknownAnnotation => "the op names an annotation that no page of the document lists",
1070 Self::AnnotationLocked => "the annotation's flags forbid the change: Locked forbids deleting it or changing its properties, LockedContents changing its contents",
1071 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",
1072 Self::NotALink => "a link op names an annotation that isn't a link",
1073 Self::LinkNotTagged => "the file claims PDF/UA-1 but has no structure tree for a new link to join",
1074 Self::AppearanceUnavailable => "the document has no appearance generator, so it can't draw a new annotation",
1075 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",
1076 Self::AnnotationGlyphMissing => "a character of a text box is in none of its fonts, so it can't be drawn",
1077 Self::AnnotationFontInvalid => "a text box's font bytes aren't a font Lamina PDF can read and embed",
1078 Self::StampImageInvalid => "an image stamp's bytes aren't a JPEG or PNG image Lamina PDF can read",
1079 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",
1080 Self::ContentObjectStale => "an edit names a content object whose bytes are no longer what the edit expects, so it would change another object",
1081 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",
1082 Self::UnknownBlob => "an op names bytes by an ID that were not added to the session",
1083 Self::ImagesUnavailable => "the document has no image writer, so it can't put a replacement image in the file",
1084 Self::FlattenWidget => "flattening names a form field's widget, which annotation flattening leaves alone",
1085 Self::UnknownAttachment => "an attachment op names an attachment the document doesn't hold",
1086 Self::AttachmentTooLarge => "a file to attach is larger than the document can read back out, so it wasn't attached",
1087 Self::UnknownField => "a form op names a field the form doesn't have",
1088 Self::FieldIsSignature => "a form-filling op names a signature field, whose value only signing writes",
1089 Self::SignFieldSigned => "the signature field a Sign op names already holds a signature",
1090 Self::SignCertifyNotFirst => "a Sign op asks to certify a document that already holds a signature",
1091 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",
1092 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)",
1093 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",
1094 Self::PdfaFieldActions => "a push button's form action, or a field's format, validation or calculation script, is one that PDF/A forbids",
1095 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",
1096 Self::TabOrderInvalid => "a custom tab order doesn't list every widget of the page exactly once",
1097 Self::ContentIdInUse => "an object added to a page has an ID that another object Lamina PDF added to that page already has",
1098 Self::UnknownContentObject => "the op names an added object that the page doesn't draw",
1099 Self::UnknownPageMark => "the op names a page mark (a watermark, background, header or footer, or Bates number) that the page doesn't draw",
1100 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",
1101 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",
1102 Self::ContentGlyphMissing => "a character of text added to a page is in none of its fonts, so it can't be drawn",
1103 Self::ContentFontInvalid => "a font given for text added to a page isn't a font Lamina PDF can read and embed",
1104 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",
1105 Self::EncryptionNoPassword => "a request to encrypt a file gave neither a user password nor an owner password",
1106 Self::EncryptionPdfaConflict => "a request to encrypt a file that claims PDF/A, which forbids encryption",
1107 Self::SecretMissing => "an operation needs a password that an op log left out, since logs never store passwords",
1108 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",
1109 Self::NotEncrypted => "a request to remove the protection of a file that isn't encrypted",
1110 Self::SanitiseIncomplete => "a sanitising edit checked the document after its removals and found something it should have removed, so the edit was undone",
1111 Self::SanitiseLimit => "a sanitising edit ran out of the work it may do on one file, or met an object nested deeper than it reads, so it removed nothing",
1112 Self::RedactionMarkMissing => "a redaction to apply names a mark that is gone or isn't a redaction mark",
1113 Self::RedactionIncomplete => "applying redactions met content it can't remove safely on a page a mark is on (text it can't read or place, content inside a form, or a page that can't be parsed), so nothing was removed",
1114 Self::Sink => "the sink failed to take the bytes or could not give them back",
1115 Self::NotRebased => "the output was written, but rebasing the document onto it failed",
1116 Self::SinkNotEmpty => "the sink already held bytes before the save started",
1117 Self::WouldInvalidateSignatures => "the save would break one or more signatures",
1118 Self::RequiresRewrite => "an incremental save was requested but only a full rewrite is safe",
1119 Self::EncryptionIncomplete => "a string or stream could not be encrypted, so the save wrote nothing",
1120 Self::EncryptionNoEntropy => "a save that encrypts the file was given no random bytes to encrypt with",
1121 Self::SignPlaceholderTooSmall => "the signature doesn't fit the space reserved for it in the file",
1122 Self::SignKeyUnsupported => "the signing certificate or its key isn't one lamina signs with",
1123 Self::SignSignerFailed => "the signer couldn't sign, or what it returned isn't a signature of its key's algorithm",
1124 Self::SignDocumentChanged => "the document changed after the signature was prepared, or isn't the document it was prepared for",
1125 Self::SignatureMalformed => "a signature's dictionary, /ByteRange or /Contents breaks a structural rule, so the signature is never valid",
1126 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",
1127 Self::InvalidFont => "font bytes could not be read as a font",
1128 Self::CollectionIndex => "a font collection member past the end of the collection was asked for",
1129 Self::UnknownAxis => "an instance was asked for on a variation axis the font does not have",
1130 Self::FontNotEmbeddable => "the font's OS/2 fsType forbids embedding",
1131 Self::MissingGlyph => "the font has no glyph for a character of the text",
1132 Self::GlyphOutOfRange => "a glyph ID at or past the font's glyph count was used",
1133 Self::UnknownFont => "a FontKey was used with a registry that did not hand it out",
1134 Self::SubsetFailed => "subsetting a font failed",
1135 Self::InvalidAxisValue => "a variation axis value was NaN or infinite",
1136 Self::WrongDocument => "finish_fonts was given a document the registry did not reserve its fonts in",
1137 Self::InvalidFeature => "an OpenType feature setting did not parse",
1138 Self::InvalidTextRange => "a byte range was out of bounds or not on character boundaries of the text",
1139 Self::InvalidSpans => "the styled spans given for a paragraph do not cover its text once, in order",
1140 Self::UnsupportedLayoutOption => "a layout option that is not implemented yet was asked for",
1141 Self::FontMismatch => "a shaped run was given with a font key for a different font than it was shaped with",
1142 Self::EncodingFull => "a standard 14 font has no free one-byte code left for another glyph",
1143 Self::FontNotShapable => "a standard 14 font was given to shaping or layout, which need a font program",
1144 Self::InvalidImage => "image bytes are not a readable image of the format they were given as",
1145 Self::UnsupportedImage => "the image uses a feature that PDF or Lamina PDF does not support",
1146 Self::ImageTooLarge => "the image needs more memory than the builder allows (a decoded PNG over 256 MiB, or raw dimensions whose size overflows)",
1147 Self::ImageDataLength => "raw image samples are not width x height x channels bytes long",
1148 Self::InvalidIccProfile => "the bytes are not a usable ICC profile",
1149 Self::ColorComponents => "a colour has the wrong number of components for its colour space",
1150 Self::InvalidColor => "a colour string is not of the form #rgb or #rrggbb",
1151 Self::InvalidGeometry => "a page size, box, /UserUnit, drawing value (coordinate, matrix, line width, dash, miter limit) or image size is not usable",
1152 Self::TextOverflow => "a text box's lines don't all fit its height and its options asked for an error",
1153 Self::PageIndexOutOfRange => "a link, outline item or destination names a page index the document doesn't have",
1154 Self::UnknownDestination => "a link or outline item names a destination that was never defined",
1155 Self::InvalidPageLabels => "page label ranges that don't start at page 0, don't increase, start past the last page or number from 0",
1156 Self::TagElementNotOpen => "a structure element resumed or closed isn't open",
1157 Self::TagElementUnclosed => "structure elements opened across pages were never closed",
1158 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)",
1159 Self::MissingTitle => "PDF/UA-1 needs a document title, and the metadata gives none",
1160 Self::MissingLang => "PDF/UA-1 needs the document's natural language, and none was set",
1161 Self::MissingAltText => "a Figure or Formula has no alternate text (/Alt or /ActualText), which PDF/UA-1 requires",
1162 Self::UntaggedContent => "content was drawn outside every structure element and artifact, which PDF/UA-1 forbids",
1163 Self::HeadingLevelSkipped => "a heading skips a level (the first is not H1, or an H3 follows an H1), which PDF/UA-1 forbids",
1164 Self::UnnumberedHeadingMisused => "an unnumbered H heading shares its parent with another H, or the document also uses H1-H6, which PDF/UA-1 forbids",
1165 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)",
1166 Self::LinkWithoutStructure => "a link annotation has no Link structure element (it was drawn inside an artifact), which PDF/UA-1 forbids",
1167 Self::LinkWithoutContents => "a link annotation has no description (/Contents), which PDF/UA-1 requires",
1168 Self::FontNotEmbedded => "a standard 14 font, which is never embedded, was used under a profile that needs every font embedded",
1169 Self::GlyphWithoutUnicode => "a glyph was drawn without a Unicode value, which PDF/A-2u and PDF/UA-1 forbid",
1170 Self::DeviceColorWithoutOutputIntent => "a DeviceCMYK colour or image was used, but the PDF/A output intent is sRGB",
1171 Self::EmbeddedFileForbidden => "PDF/A-2 doesn't allow attached files that aren't PDF/A themselves",
1172 Self::EmbeddedFileWithoutMimeType => "an attached file has no MIME type, which every PDF/A profile requires",
1173 Self::FlowContentTooLarge => "a line or a figure of a flow is taller than the page's body, so no page can hold it",
1174 Self::FlowLayoutUnstable => "a flow's contents page kept changing its page numbers after four layouts",
1175 Self::InvalidDocument => "a laminapdf.document/1 document has an unknown key, a missing one or a value of the wrong kind",
1176 Self::TemplateDataMissing => "a template's $data, $each or $item points to a value the data doesn't have",
1177 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",
1178 Self::TemplateTooLarge => "a template would fill in more values, or nest deeper, than a document may hold",
1179 Self::RenderTooLarge => "the requested tile is larger than the render limits allow; nothing was allocated",
1180 Self::RenderFailed => "the render engine could not open the document or draw the page",
1181 Self::RenderBackendUnavailable => "the render engine is not available: its library or module could not be loaded",
1182 Self::ExportFailed => "an export's PNG, JPEG or TIFF encoder failed on a page that was drawn",
1183 Self::ModelFailed => "a layout model, OCR engine or page renderer plugged into an extraction failed; the extraction stops with no partial result",
1184 Self::ModelResultUnexpected => "a model result was handed to an extraction job that hadn't asked for it, or was the other model's result",
1185 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",
1186 Self::InterchangeUnknownFormat => "the bytes given to import are neither XFDF nor FDF, nor JSON for form data",
1187 Self::InterchangeMalformed => "the XFDF, FDF or form data JSON file doesn't read; the error names the line where reading stopped",
1188 Self::InterchangeDtd => "the XFDF file declares a DTD, which could define entities that expand without end or read other files, so it is refused",
1189 Self::SubmitPdfRefused => "a form action asks to send the whole PDF, which Lamina PDF never does: only field values leave the device",
1190 Self::SubmitUrlRefused => "a form action's address isn't an https: address, so nothing is sent",
1191 Self::InterchangeTooLarge => "the exchange file is larger than the document's limits allow",
1192 Self::Cancelled => "a CancelToken stopped the work; the job is finished and returned no partial result",
1193 Self::JobFinished => "a job was stepped after it had finished, failed or been cancelled",
1194 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",
1195 Self::RevisionIndexOutOfRange => "an earlier revision was asked for by an index past the file's last revision",
1196 Self::NoBookmarks => "a contents page was asked for, but no bookmark goes to a page of the document, so it would list nothing",
1197 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",
1198 Self::BuilderFinished => "a builder or one of its pages was used after it finished",
1199 Self::Disposed => "a document, builder or other handle was used after free(), or after the using block that held it ended",
1200 Self::InvalidArgument => "a value passed to a binding does not have the shape its type declares",
1201 Self::SourceBudgetExceeded => "a sparse source was given more bytes than its byte budget allows",
1202 Self::UnknownOption => "an options record passed to a binding has a key Lamina PDF does not know",
1203 Self::InvalidCommandLine => "the command line doesn't parse: an unknown command or flag, a missing argument, a bad value, or stdin named twice",
1204 Self::InvalidPageRange => "a page range doesn't fit the grammar, or names a page the document lacks",
1205 Self::BinaryOutputToTerminal => "the command would write a PDF to standard output, and standard output is a terminal",
1206 Self::UnknownCode => "explain was given a code that isn't a Lamina PDF error or warning code",
1207 Self::OverwriteRefused => "the output file exists, or the command would modify its input in place, and --force wasn't given",
1208 Self::InputUnreadable => "an input file, standard input or the password file couldn't be read",
1209 Self::OutputUnwritable => "the output couldn't be written: its folder is missing or read-only, the disk is full, or standard output closed",
1210 Self::PathOutsideRoots => "laminapdf mcp was given a path outside its --root folders, or a link that leads out of them",
1211 }
1212 }
1213
1214 #[must_use]
1218 pub const fn hint(self) -> &'static str {
1219 match self {
1220 Self::NotPdf => "check that the bytes passed to open are a PDF file",
1221 Self::MissingRoot => "use another copy of the file: this one has no usable catalog",
1222 Self::ReferenceCycle => "use another copy of the file, or repair it with another tool",
1223 Self::LimitExceeded => "the input exceeds a safety limit; raise {limit} in Limits only if you trust the input",
1224 Self::Strict => "open without strict mode to read the file with repairs, or fix the file",
1225 Self::DataPending => "fetch the listed ranges into the source and retry the call",
1226 Self::Source => "retry the call, or check the source; the document stays usable",
1227 Self::Type => "use another copy of the file, or repair it with another tool",
1228 Self::InvalidStructure => "use another copy of the file, or repair it with another tool",
1229 Self::UnsetObject => "this is a bug in Lamina PDF: report it with the steps that led to it",
1230 Self::RepairedBase => "save with a full rewrite instead of an incremental update",
1231 Self::EncryptedBase => "save through Save::save with an entropy seed to keep the protection, or apply RemoveEncryption to drop it",
1232 Self::PasswordRequired => "pass the document's password in OpenOptions",
1233 Self::WrongPassword => "ask for the password again and retry with the correct one",
1234 Self::UnsupportedSecurityHandler => "use a tool that supports this encryption to decrypt the file first",
1235 Self::UnexpectedEof => "use a complete copy of the file: this one looks truncated",
1236 Self::Syntax => "use another copy of the file, or repair it with another tool",
1237 Self::UnsupportedFilter => "use a tool that supports the filter to read this stream",
1238 Self::Decompress => "use another copy of the file: this stream's data is damaged",
1239 Self::NestedTransaction => "commit or roll back the open transaction first, or use a savepoint inside it",
1240 Self::NoTransaction => "call begin first, or use transact",
1241 Self::UnknownPage => "use a PageId from this document's pages()",
1242 Self::DirectPage => "rewrite the file so that every page is an indirect object, or wait for page-structure ops",
1243 Self::UnsupportedVersion => "upgrade Lamina PDF to a version that reads this op log version",
1244 Self::InvalidOpLog => "validate the op log against the op schema; the samples in fixtures/ops show the format",
1245 Self::SavedNotRebased => "call rebase with the saved bytes before applying ops or saving again",
1246 Self::NoPendingSave => "call rebase only after a save that returned SavedNotRebased",
1247 Self::MalformedXmp => "set replaceMalformed on the edit to replace the packet with a new one, or leave the metadata as it is",
1248 Self::UnknownSource => "add the source document's bytes with addSource before applying ops that name it",
1249 Self::OpenActionNotDestination => "leave the open page out of the edit, which keeps the open action as it is",
1250 Self::UnknownOutlineItem => "read the outline again and use one of its item IDs; an item a previous op deleted is gone",
1251 Self::DirectOutlineItem => "apply any other outline op first: it rewrites the outline and gives every bookmark an object and an ID of its own",
1252 Self::OutlineNotASibling => "name a position among the parent's own children, or use first or last",
1253 Self::OutlineMoveIntoItself => "choose a parent outside the bookmark's own branch",
1254 Self::UnknownNamedDestination => "list the file's named destinations and use one of their names",
1255 Self::NamedDestinationExists => "choose a name no destination has, or delete the other one first",
1256 Self::EmptyDestinationName => "give the destination a name of at least one character",
1257 Self::LinkUriRefused => "use a full address such as https://example.com/page; encode other characters with %",
1258 Self::ViewNotFinite => "pass finite numbers, or null to keep the viewer's current value",
1259 Self::XmpClaimReadOnly => "leave the pdfaid: and pdfuaid: properties as they are; edit the other properties, or keep them unchanged in a replaced packet",
1260 Self::InvalidXmpPacket => "fix the XML at the offset in the error's data (reason says what is wrong), then replace the packet again",
1261 Self::InvalidXmpProperty => "check the part the error's reason names: the namespace, prefix, name, value, or the shape a mirrored property needs",
1262 Self::NoPagesLeft => "keep at least one page: delete all but one, or insert a blank page first",
1263 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",
1264 Self::UnknownAnnotation => "read the page's annotations again and use an ID from that list",
1265 Self::AnnotationLocked => "clear the lock with an update of its flags first, if you may",
1266 Self::AnnotationNotEditable => "edit a widget through its form field; an annotation stored inside the page's list can't be edited yet",
1267 Self::NotALink => "name a link from the page's links; change other annotations with updateAnnot and deleteAnnot",
1268 Self::LinkNotTagged => "tag the document first, or add the link to a copy that doesn't claim PDF/UA",
1269 Self::AppearanceUnavailable => "edit through the laminapdf crate, which draws appearances, or give laminapdf-ops a generator with Document::with_appearances",
1270 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)",
1271 Self::AnnotationGlyphMissing => "add a fallback font that has the character, or give the box a font that has it",
1272 Self::AnnotationFontInvalid => "give the bytes of a TrueType or OpenType font whose licence allows embedding",
1273 Self::StampImageInvalid => "add the bytes of a JPEG or PNG file and name that blob as the stamp's image",
1274 Self::InvalidLabelRanges => "give ranges in page order, the first on the document's first page, each numbered from 1 or more",
1275 Self::ContentObjectStale => "read the page's content objects again and name the object from that list",
1276 Self::ContentNotEditable => "the content stays selectable and readable; the reason says why it can't be changed",
1277 Self::UnknownBlob => "add the bytes with addBlob before applying ops that name them",
1278 Self::ImagesUnavailable => "edit through the laminapdf crate, which writes images, or give laminapdf-ops a writer with Document::with_images",
1279 Self::FlattenWidget => "leave widgets out of the annotations to flatten, and use flattenForm for form fields; a signature field is never flattened",
1280 Self::UnknownAttachment => "read the attachments again and use an ID from that list: the attachment was deleted, or the ID comes from another document",
1281 Self::AttachmentTooLarge => "attach a smaller file, or open the document with a higher maxStreamDecoded limit",
1282 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",
1283 Self::FieldIsSignature => "leave signature fields out of the values to set; sign the field instead",
1284 Self::SignFieldSigned => "sign another signature field, or a new one; a field is signed once",
1285 Self::SignCertifyNotFirst => "sign it without certify, or certify a copy that has no signature yet; a certification must be the first signature",
1286 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",
1287 Self::FieldNameTaken => "give the field another name, or delete or rename the field that holds it",
1288 Self::FieldNameInvalid => "name the field with parts that hold text, joined by single periods, and not below a field that has widgets",
1289 Self::PdfaFieldActions => "leave the ResetForm action or the helper scripts off a file that claims PDF/A; a SubmitForm button is allowed",
1290 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",
1291 Self::TabOrderInvalid => "list each widget annotation of the page once, no more and no fewer, and none from another page",
1292 Self::ContentIdInUse => "choose an ID no other added object on the page has, or update that object instead",
1293 Self::UnknownContentObject => "read the page's added objects again and use an ID from that list",
1294 Self::UnknownPageMark => "read the page's marks again and use an ID from that list",
1295 Self::ContentObjectInvalid => "add the bytes of a JPEG or PNG file, or of a PDF and a page it has, and name that blob",
1296 Self::ContentNeedsAltText => "give the image alternate text, or mark it as decoration so screen readers skip it",
1297 Self::ContentGlyphMissing => "add a fallback font that has the character (a symbol font for symbols), or give the text a font that has it",
1298 Self::ContentFontInvalid => "give the bytes of a TrueType or OpenType font, or one of helvetica, times and courier",
1299 Self::ContentFontNotEmbeddable => "use a font whose licence allows embedding, such as one of the bundled fonts, or one of helvetica, times and courier",
1300 Self::EncryptionNoPassword => "give a password that opens the file, a permissions password, or both",
1301 Self::EncryptionPdfaConflict => "remove the PDF/A claim first, or keep the file unprotected",
1302 Self::SecretMissing => "give the password again when you apply the operation",
1303 Self::OwnerPasswordRequired => "ask for the file's permissions (owner) password and give it before changing the protection",
1304 Self::NotEncrypted => "check whether the file is encrypted before offering to remove its protection",
1305 Self::SanitiseIncomplete => "report the file: nothing was removed or saved; the other sanitising options may still work on it",
1306 Self::SanitiseLimit => "the file is unusually large or deep: sanitise its categories one at a time, or simplify the file first",
1307 Self::RedactionMarkMissing => "read the marks again (redactionMarks) and apply the ones that are there",
1308 Self::RedactionIncomplete => "nothing was changed or saved; report the file, or remove the marks on that page and redact it another way",
1309 Self::Sink => "check the destination and retry the save; the document is unchanged",
1310 Self::NotRebased => "retry rebase with the saved output carried by the error",
1311 Self::SinkNotEmpty => "pass an empty sink: output offsets count from the sink's first byte",
1312 Self::WouldInvalidateSignatures => "save with SaveMode::Auto, or ask the user and retry with SaveOptions::with_invalidate_signatures",
1313 Self::RequiresRewrite => "save with SaveMode::Auto or SaveMode::FullRewrite",
1314 Self::EncryptionIncomplete => "report this as a bug with the file that triggers it; a file encrypted in part would leak its plain parts",
1315 Self::EncryptionNoEntropy => "pass an entropy seed of 32 bytes from crypto.getRandomValues or getrandom when you save",
1316 Self::SignPlaceholderTooSmall => "prepare the signature again with the reserve the error reports; nothing was written",
1317 Self::SignKeyUnsupported => "use an X.509 certificate with an ECDSA P-256, ECDSA P-384 or RSA key, the signer's own first",
1318 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",
1319 Self::SignDocumentChanged => "prepare the signature again after the last edit, and finish it on the same document before editing more",
1320 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",
1321 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",
1322 Self::InvalidFont => "pass the complete bytes of a .ttf, .otf, .ttc or .otc file",
1323 Self::CollectionIndex => "use an index below Font::collection_len",
1324 Self::UnknownAxis => "check the font's axes before choosing coordinates, or use a variable font",
1325 Self::FontNotEmbeddable => "use another font, or register it with EmbedPolicy::Override if your licence allows embedding",
1326 Self::MissingGlyph => "use a font that covers the character, or split the text across fonts",
1327 Self::GlyphOutOfRange => "pass glyph IDs from the font you registered",
1328 Self::UnknownFont => "use the key returned by this registry's add",
1329 Self::SubsetFailed => "try another version or format of the font, and report the font if it is a common one",
1330 Self::InvalidAxisValue => "pass finite axis values; values outside the axis range are clamped",
1331 Self::WrongDocument => "use one FontRegistry per document and finish it with that document",
1332 Self::InvalidFeature => "write it as liga=0, -liga, smcp or aalt=2 (HarfBuzz syntax without ranges)",
1333 Self::InvalidTextRange => "take ranges from Lamina PDF's results (line_breaks, itemize, break_lines) and pass the same text",
1334 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",
1335 Self::UnsupportedLayoutOption => "leave the option at its default; justification comes with a later release",
1336 Self::FontMismatch => "pass the key of the font the run was shaped with (the font index of each line run maps to your keys)",
1337 Self::EncodingFull => "embed a font with Font::from_bytes, or split the text across two registrations of the standard font",
1338 Self::FontNotShapable => "draw standard 14 fonts with FontRegistry::encode, or shape with an embedded font",
1339 Self::InvalidImage => "pass the complete bytes of a JPEG or PNG file to Image::jpeg or Image::png",
1340 Self::UnsupportedImage => "convert it to a baseline or progressive 8-bit JPEG, or to PNG",
1341 Self::ImageTooLarge => "scale the image down before adding it",
1342 Self::ImageDataLength => "pass exactly 4 bytes (RGBA) per pixel, row by row",
1343 Self::InvalidIccProfile => "pass a complete ICC profile with a Gray, RGB or CMYK data colour space",
1344 Self::ColorComponents => "give one component per channel of the colour space (/N of the ICC profile)",
1345 Self::InvalidColor => "write the colour as # followed by 3 or 6 hexadecimal digits",
1346 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",
1347 Self::TextOverflow => "make the box taller or the text shorter, or use Overflow::Clip and read TextLayout::overflow",
1348 Self::PageIndexOutOfRange => "use a 0-based index below the document's page count",
1349 Self::UnknownDestination => "define it with Builder::destination before the build finishes, or link to a page",
1350 Self::InvalidPageLabels => "give ranges sorted by first page, the first at page 0, numbered from 1",
1351 Self::TagElementNotOpen => "resume and close only elements this builder's pages opened with open_element, and close each once",
1352 Self::TagElementUnclosed => "close each element from open_element with Builder::close_element once its last page is finished",
1353 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",
1354 Self::MissingTitle => "set a title with Builder::metadata (Metadata::with_title)",
1355 Self::MissingLang => "set the language with Builder::lang, such as \"en-GB\"",
1356 Self::MissingAltText => "give the figure or formula a description with Tag::with_alt or Surface::figure's alt, or draw decoration as an artifact",
1357 Self::UntaggedContent => "draw it inside Surface::tag (real content) or Surface::artifact (decoration)",
1358 Self::HeadingLevelSkipped => "start with H1 and go down one level at a time",
1359 Self::UnnumberedHeadingMisused => "use numbered headings (H1, H2, ...) throughout, or one H per section",
1360 Self::InvalidStructureNesting => "nest tables as Table > TR > TH/TD and lists as L > LI > Lbl/LBody",
1361 Self::LinkWithoutStructure => "draw links outside artifacts, so the builder gives each one a Link element",
1362 Self::LinkWithoutContents => "pass a description as the link's contents",
1363 Self::FontNotEmbedded => "load a font file with Builder::font instead of Builder::standard_font",
1364 Self::GlyphWithoutUnicode => "remove NUL characters (U+0000) from the text, or choose PDF/A-2b, which doesn't need Unicode",
1365 Self::DeviceColorWithoutOutputIntent => "use RGB or gray colours, or a CMYK colour with an ICC profile (Color::icc)",
1366 Self::EmbeddedFileForbidden => "choose PDF/A-3b, which allows attached files of any kind",
1367 Self::EmbeddedFileWithoutMimeType => "pass the file's MIME type, such as text/xml or application/octet-stream",
1368 Self::FlowContentTooLarge => "make the figure smaller, the text size smaller or the page's margins narrower",
1369 Self::FlowLayoutUnstable => "report the flow that fails; a page break after the contents block may avoid it until it is fixed",
1370 Self::InvalidDocument => "data.pointer names the value; correct it against the document schema, and didYouMean lists the closest known keys",
1371 Self::TemplateDataMissing => "data.pointer names the value the template asked for; add it to the data or correct the pointer",
1372 Self::TemplateDataType => "data.pointer names the value and data.expected the kind the template needs there",
1373 Self::TemplateTooLarge => "data.limit is the limit it passed; repeat fewer items, or split the document",
1374 Self::RenderTooLarge => "request smaller tiles (256 to 512 pixels at high zoom) or raise RenderLimits if the larger bitmap is intended",
1375 Self::RenderFailed => "the file may be damaged or use a feature this engine can't draw; try the other backend, or report the file",
1376 Self::RenderBackendUnavailable => "run cargo xtask fetch-pdfium or set LAMINA_PDF_PDFIUM_DIR to the folder holding the PDFium library",
1377 Self::ExportFailed => "report it with the format and the page: the encoder writes into memory, so this is a bug in Lamina PDF",
1378 Self::ModelFailed => "check the plug-in's own logs; extract without the model to get the rules-only result",
1379 Self::ModelResultUnexpected => "call provide only while request() returns a request, with the result its kind asks for",
1380 Self::ModelNeedsHost => "step an extraction job and hand it each result with provide, or give the plug-in a page renderer",
1381 Self::InterchangeUnknownFormat => "pass an .xfdf or .fdf file exported from a PDF app, or form data JSON",
1382 Self::InterchangeMalformed => "open the file in a text editor at that line, or export the comments again",
1383 Self::InterchangeDtd => "export the comments again from the app that made the file; XFDF needs no DTD",
1384 Self::SubmitPdfRefused => "export the form data and send that file instead",
1385 Self::SubmitUrlRefused => "ask the form's sender for an https: address, or export the form data and send that file",
1386 Self::InterchangeTooLarge => "raise Limits::max_stream_decoded if the file is expected to be this large",
1387 Self::Cancelled => "nothing to do: this is the outcome the caller asked for; start a new job to try again",
1388 Self::JobFinished => "stop stepping a job once a step returned its result or an error; create a new job",
1389 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",
1390 Self::RevisionIndexOutOfRange => "ask for an index below the document's revision count",
1391 Self::NoBookmarks => "add bookmarks that go to the document's pages first, then create the contents page",
1392 Self::SoundUnavailable => "check the annotation's subtype and sound format in its record before asking for its samples",
1393 Self::BuilderFinished => "create a new builder or page: a finished one takes no more drawing, pages, fonts or settings",
1394 Self::Disposed => "free a handle only after its last use; to keep working, open the document again or create a new builder",
1395 Self::InvalidArgument => "pass the value the type declarations describe; the data field says what was wrong",
1396 Self::SourceBudgetExceeded => "raise the source's budget, or open the file with fewer bytes fetched (smaller blocks, no readahead)",
1397 Self::UnknownOption => "remove the key or correct its spelling; didYouMean lists the closest known names",
1398 Self::InvalidCommandLine => "run the command with --help to see its arguments",
1399 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",
1400 Self::BinaryOutputToTerminal => "redirect standard output to a file or a pipe, or write to a file with -o",
1401 Self::UnknownCode => "check the spelling against didYouMean, or list every code at the docs URL",
1402 Self::OverwriteRefused => "pass --force, or write to a new file with -o",
1403 Self::InputUnreadable => "check that the file exists and that you can read it; data.input names it",
1404 Self::OutputUnwritable => "check that the output's folder exists, that you can write to it and that the disk has room",
1405 Self::PathOutsideRoots => "use a path inside one of the server's --root folders, or start the server with another --root",
1406 }
1407 }
1408
1409 #[must_use]
1413 pub fn docs_url(self) -> String {
1414 format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
1415 }
1416}
1417
1418#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1422#[non_exhaustive]
1423pub enum WarningCode {
1424 MissingHeader,
1426 XrefRepaired,
1428 XrefstmIgnored,
1430 StreamLengthRecovered,
1432 DictionaryKeySkipped,
1434 StaleGeneration,
1436 PageTreeNodeSkipped,
1438 PageCountMismatch,
1440 FlateTruncated,
1442 FilterCharactersSkipped,
1444 ObjstmIndexMismatch,
1446 ObjectNumberOutOfRange,
1448 AesPaddingInvalid,
1450 PermsMismatch,
1452 WarningsTruncated,
1454 InvalidBox,
1456 InvalidRotate,
1458 NameTreeNodeSkipped,
1460 OutlineCycle,
1462 OutlineItemSkipped,
1464 InvalidDate,
1466 XmpInvalid,
1468 AnnotNameDuplicate,
1470 XmpRepaired,
1472 InvalidPageLabel,
1474 InvalidEntry,
1476 ContentUnknownOperator,
1478 ContentBadOperands,
1480 ContentUnbalancedQ,
1482 ContentUnbalancedBt,
1484 ContentUnbalancedMarked,
1486 ContentSyntax,
1488 ContentResourceMissing,
1490 InlineImageUnterminated,
1492 XobjectCycle,
1494 ContentPathUnpainted,
1496 FontInvalid,
1498 CmapInvalid,
1500 UnmappedGlyph,
1502 ExtractLimitBlocks,
1504 ExtractReadingOrderAmbiguous,
1506 ExtractTableAmbiguous,
1508 ExtractTableLimit,
1510 ExtractStructTreeIgnored,
1512 ExtractUntaggedContent,
1514 ExtractNeedsOcr,
1516 ExtractColumnOrderUncertain,
1518 PdfaOneAuthor,
1520 PdfuaTitleMissing,
1522 PdfaInfoMismatch,
1524 DuplicateTagsIncomplete,
1526 ImportedTagsDropped,
1528 ImportedPdfaUnchecked,
1530 ImportedPdfuaUnchecked,
1532 AnnotWithoutContents,
1534 AnnotNotTagged,
1536 FieldLabelMissing,
1538 PdfaAnnotFlags,
1540 PdfaTransparency,
1542 PdfaFontNotEmbedded,
1544 FlattenUntagged,
1546 FigureWithoutAlt,
1548 ContentTagsBroken,
1550 PdfaAttachmentForbidden,
1552 PdfaAttachmentIncomplete,
1554 PdfaColorSpace,
1556 PdfaOptionalContent,
1558 FieldFormattingRemoved,
1560 XfaOnlyContentRemoved,
1562 ConformanceClaimRemoved,
1564 RedactionMarksKept,
1566 HiddenContentKept,
1568 TounicodeConflict,
1570 WholeFontRebuilt,
1572 FlowKeepBroken,
1574 MarkdownHtmlIgnored,
1576 MarkdownImageMissing,
1578 InterchangeSkipped,
1580 InterchangeDocumentMismatch,
1582 CoveredText,
1584 RedactionNotApplied,
1586 TextInEarlierRevision,
1588 RichTextSimplified,
1590 FlattenNoAppearance,
1592 AttachmentStillHeld,
1594 XfaRemoved,
1596 FieldNameStillUsed,
1598 FieldScriptReplaced,
1600 SummaryPageNotDrawn,
1602}
1603
1604impl WarningCode {
1605 pub const ALL: &'static [Self] = &[
1609 Self::MissingHeader,
1610 Self::XrefRepaired,
1611 Self::XrefstmIgnored,
1612 Self::StreamLengthRecovered,
1613 Self::DictionaryKeySkipped,
1614 Self::StaleGeneration,
1615 Self::PageTreeNodeSkipped,
1616 Self::PageCountMismatch,
1617 Self::FlateTruncated,
1618 Self::FilterCharactersSkipped,
1619 Self::ObjstmIndexMismatch,
1620 Self::ObjectNumberOutOfRange,
1621 Self::AesPaddingInvalid,
1622 Self::PermsMismatch,
1623 Self::WarningsTruncated,
1624 Self::InvalidBox,
1625 Self::InvalidRotate,
1626 Self::NameTreeNodeSkipped,
1627 Self::OutlineCycle,
1628 Self::OutlineItemSkipped,
1629 Self::InvalidDate,
1630 Self::XmpInvalid,
1631 Self::AnnotNameDuplicate,
1632 Self::XmpRepaired,
1633 Self::InvalidPageLabel,
1634 Self::InvalidEntry,
1635 Self::ContentUnknownOperator,
1636 Self::ContentBadOperands,
1637 Self::ContentUnbalancedQ,
1638 Self::ContentUnbalancedBt,
1639 Self::ContentUnbalancedMarked,
1640 Self::ContentSyntax,
1641 Self::ContentResourceMissing,
1642 Self::InlineImageUnterminated,
1643 Self::XobjectCycle,
1644 Self::ContentPathUnpainted,
1645 Self::FontInvalid,
1646 Self::CmapInvalid,
1647 Self::UnmappedGlyph,
1648 Self::ExtractLimitBlocks,
1649 Self::ExtractReadingOrderAmbiguous,
1650 Self::ExtractTableAmbiguous,
1651 Self::ExtractTableLimit,
1652 Self::ExtractStructTreeIgnored,
1653 Self::ExtractUntaggedContent,
1654 Self::ExtractNeedsOcr,
1655 Self::ExtractColumnOrderUncertain,
1656 Self::PdfaOneAuthor,
1657 Self::PdfuaTitleMissing,
1658 Self::PdfaInfoMismatch,
1659 Self::DuplicateTagsIncomplete,
1660 Self::ImportedTagsDropped,
1661 Self::ImportedPdfaUnchecked,
1662 Self::ImportedPdfuaUnchecked,
1663 Self::AnnotWithoutContents,
1664 Self::AnnotNotTagged,
1665 Self::FieldLabelMissing,
1666 Self::PdfaAnnotFlags,
1667 Self::PdfaTransparency,
1668 Self::PdfaFontNotEmbedded,
1669 Self::FlattenUntagged,
1670 Self::FigureWithoutAlt,
1671 Self::ContentTagsBroken,
1672 Self::PdfaAttachmentForbidden,
1673 Self::PdfaAttachmentIncomplete,
1674 Self::PdfaColorSpace,
1675 Self::PdfaOptionalContent,
1676 Self::FieldFormattingRemoved,
1677 Self::XfaOnlyContentRemoved,
1678 Self::ConformanceClaimRemoved,
1679 Self::RedactionMarksKept,
1680 Self::HiddenContentKept,
1681 Self::TounicodeConflict,
1682 Self::WholeFontRebuilt,
1683 Self::FlowKeepBroken,
1684 Self::MarkdownHtmlIgnored,
1685 Self::MarkdownImageMissing,
1686 Self::InterchangeSkipped,
1687 Self::InterchangeDocumentMismatch,
1688 Self::CoveredText,
1689 Self::RedactionNotApplied,
1690 Self::TextInEarlierRevision,
1691 Self::RichTextSimplified,
1692 Self::FlattenNoAppearance,
1693 Self::AttachmentStillHeld,
1694 Self::XfaRemoved,
1695 Self::FieldNameStillUsed,
1696 Self::FieldScriptReplaced,
1697 Self::SummaryPageNotDrawn,
1698 ];
1699
1700 #[must_use]
1704 pub const fn from_code(code: &str) -> Option<Self> {
1705 let mut rest = Self::ALL;
1706 while let [first, tail @ ..] = rest {
1707 if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
1708 return Some(*first);
1709 }
1710 rest = tail;
1711 }
1712 None
1713 }
1714
1715 #[must_use]
1719 pub const fn as_str(self) -> &'static str {
1720 match self {
1721 Self::MissingHeader => "missing-header",
1722 Self::XrefRepaired => "xref-repaired",
1723 Self::XrefstmIgnored => "xrefstm-ignored",
1724 Self::StreamLengthRecovered => "stream-length-recovered",
1725 Self::DictionaryKeySkipped => "dictionary-key-skipped",
1726 Self::StaleGeneration => "stale-generation",
1727 Self::PageTreeNodeSkipped => "page-tree-node-skipped",
1728 Self::PageCountMismatch => "page-count-mismatch",
1729 Self::FlateTruncated => "flate-truncated",
1730 Self::FilterCharactersSkipped => "filter-characters-skipped",
1731 Self::ObjstmIndexMismatch => "objstm-index-mismatch",
1732 Self::ObjectNumberOutOfRange => "object-number-out-of-range",
1733 Self::AesPaddingInvalid => "aes-padding-invalid",
1734 Self::PermsMismatch => "perms-mismatch",
1735 Self::WarningsTruncated => "warnings-truncated",
1736 Self::InvalidBox => "invalid-box",
1737 Self::InvalidRotate => "invalid-rotate",
1738 Self::NameTreeNodeSkipped => "name-tree-node-skipped",
1739 Self::OutlineCycle => "outline-cycle",
1740 Self::OutlineItemSkipped => "outline-item-skipped",
1741 Self::InvalidDate => "invalid-date",
1742 Self::XmpInvalid => "xmp-invalid",
1743 Self::AnnotNameDuplicate => "annot-name-duplicate",
1744 Self::XmpRepaired => "xmp-repaired",
1745 Self::InvalidPageLabel => "invalid-page-label",
1746 Self::InvalidEntry => "invalid-entry",
1747 Self::ContentUnknownOperator => "content-unknown-operator",
1748 Self::ContentBadOperands => "content-bad-operands",
1749 Self::ContentUnbalancedQ => "content-unbalanced-q",
1750 Self::ContentUnbalancedBt => "content-unbalanced-bt",
1751 Self::ContentUnbalancedMarked => "content-unbalanced-marked",
1752 Self::ContentSyntax => "content-syntax",
1753 Self::ContentResourceMissing => "content-resource-missing",
1754 Self::InlineImageUnterminated => "inline-image-unterminated",
1755 Self::XobjectCycle => "xobject-cycle",
1756 Self::ContentPathUnpainted => "content-path-unpainted",
1757 Self::FontInvalid => "font-invalid",
1758 Self::CmapInvalid => "cmap-invalid",
1759 Self::UnmappedGlyph => "unmapped-glyph",
1760 Self::ExtractLimitBlocks => "extract-limit-blocks",
1761 Self::ExtractReadingOrderAmbiguous => "extract-reading-order-ambiguous",
1762 Self::ExtractTableAmbiguous => "extract-table-ambiguous",
1763 Self::ExtractTableLimit => "extract-table-limit",
1764 Self::ExtractStructTreeIgnored => "extract-struct-tree-ignored",
1765 Self::ExtractUntaggedContent => "extract-untagged-content",
1766 Self::ExtractNeedsOcr => "extract-needs-ocr",
1767 Self::ExtractColumnOrderUncertain => "extract-column-order-uncertain",
1768 Self::PdfaOneAuthor => "pdfa-one-author",
1769 Self::PdfuaTitleMissing => "pdfua-title-missing",
1770 Self::PdfaInfoMismatch => "pdfa-info-mismatch",
1771 Self::DuplicateTagsIncomplete => "duplicate-tags-incomplete",
1772 Self::ImportedTagsDropped => "imported-tags-dropped",
1773 Self::ImportedPdfaUnchecked => "imported-pdfa-unchecked",
1774 Self::ImportedPdfuaUnchecked => "imported-pdfua-unchecked",
1775 Self::AnnotWithoutContents => "annot-without-contents",
1776 Self::AnnotNotTagged => "annot-not-tagged",
1777 Self::FieldLabelMissing => "field-label-missing",
1778 Self::PdfaAnnotFlags => "pdfa-annot-flags",
1779 Self::PdfaTransparency => "pdfa-transparency",
1780 Self::PdfaFontNotEmbedded => "pdfa-font-not-embedded",
1781 Self::FlattenUntagged => "flatten-untagged",
1782 Self::FigureWithoutAlt => "figure-without-alt",
1783 Self::ContentTagsBroken => "content-tags-broken",
1784 Self::PdfaAttachmentForbidden => "pdfa-attachment-forbidden",
1785 Self::PdfaAttachmentIncomplete => "pdfa-attachment-incomplete",
1786 Self::PdfaColorSpace => "pdfa-color-space",
1787 Self::PdfaOptionalContent => "pdfa-optional-content",
1788 Self::FieldFormattingRemoved => "field-formatting-removed",
1789 Self::XfaOnlyContentRemoved => "xfa-only-content-removed",
1790 Self::ConformanceClaimRemoved => "conformance-claim-removed",
1791 Self::RedactionMarksKept => "redaction-marks-kept",
1792 Self::HiddenContentKept => "hidden-content-kept",
1793 Self::TounicodeConflict => "tounicode-conflict",
1794 Self::WholeFontRebuilt => "whole-font-rebuilt",
1795 Self::FlowKeepBroken => "flow-keep-broken",
1796 Self::MarkdownHtmlIgnored => "markdown-html-ignored",
1797 Self::MarkdownImageMissing => "markdown-image-missing",
1798 Self::InterchangeSkipped => "interchange-skipped",
1799 Self::InterchangeDocumentMismatch => "interchange-document-mismatch",
1800 Self::CoveredText => "covered-text",
1801 Self::RedactionNotApplied => "redaction-not-applied",
1802 Self::TextInEarlierRevision => "text-in-earlier-revision",
1803 Self::RichTextSimplified => "rich-text-simplified",
1804 Self::FlattenNoAppearance => "flatten-no-appearance",
1805 Self::AttachmentStillHeld => "attachment-still-held",
1806 Self::XfaRemoved => "xfa-removed",
1807 Self::FieldNameStillUsed => "field-name-still-used",
1808 Self::FieldScriptReplaced => "field-script-replaced",
1809 Self::SummaryPageNotDrawn => "summary-page-not-drawn",
1810 }
1811 }
1812
1813 #[must_use]
1817 pub const fn kind(self) -> ErrorKind {
1818 match self {
1819 Self::MissingHeader => ErrorKind::Input,
1820 Self::XrefRepaired => ErrorKind::Input,
1821 Self::XrefstmIgnored => ErrorKind::Input,
1822 Self::StreamLengthRecovered => ErrorKind::Input,
1823 Self::DictionaryKeySkipped => ErrorKind::Input,
1824 Self::StaleGeneration => ErrorKind::Input,
1825 Self::PageTreeNodeSkipped => ErrorKind::Input,
1826 Self::PageCountMismatch => ErrorKind::Input,
1827 Self::FlateTruncated => ErrorKind::Input,
1828 Self::FilterCharactersSkipped => ErrorKind::Input,
1829 Self::ObjstmIndexMismatch => ErrorKind::Input,
1830 Self::ObjectNumberOutOfRange => ErrorKind::Limit,
1831 Self::AesPaddingInvalid => ErrorKind::Security,
1832 Self::PermsMismatch => ErrorKind::Security,
1833 Self::WarningsTruncated => ErrorKind::Limit,
1834 Self::InvalidBox => ErrorKind::Input,
1835 Self::InvalidRotate => ErrorKind::Input,
1836 Self::NameTreeNodeSkipped => ErrorKind::Input,
1837 Self::OutlineCycle => ErrorKind::Input,
1838 Self::OutlineItemSkipped => ErrorKind::Input,
1839 Self::InvalidDate => ErrorKind::Input,
1840 Self::XmpInvalid => ErrorKind::Input,
1841 Self::AnnotNameDuplicate => ErrorKind::Input,
1842 Self::XmpRepaired => ErrorKind::Input,
1843 Self::InvalidPageLabel => ErrorKind::Input,
1844 Self::InvalidEntry => ErrorKind::Input,
1845 Self::ContentUnknownOperator => ErrorKind::Input,
1846 Self::ContentBadOperands => ErrorKind::Input,
1847 Self::ContentUnbalancedQ => ErrorKind::Input,
1848 Self::ContentUnbalancedBt => ErrorKind::Input,
1849 Self::ContentUnbalancedMarked => ErrorKind::Input,
1850 Self::ContentSyntax => ErrorKind::Input,
1851 Self::ContentResourceMissing => ErrorKind::Input,
1852 Self::InlineImageUnterminated => ErrorKind::Input,
1853 Self::XobjectCycle => ErrorKind::Input,
1854 Self::ContentPathUnpainted => ErrorKind::Input,
1855 Self::FontInvalid => ErrorKind::Input,
1856 Self::CmapInvalid => ErrorKind::Input,
1857 Self::UnmappedGlyph => ErrorKind::Input,
1858 Self::ExtractLimitBlocks => ErrorKind::Limit,
1859 Self::ExtractReadingOrderAmbiguous => ErrorKind::Unsupported,
1860 Self::ExtractTableAmbiguous => ErrorKind::Unsupported,
1861 Self::ExtractTableLimit => ErrorKind::Limit,
1862 Self::ExtractStructTreeIgnored => ErrorKind::Input,
1863 Self::ExtractUntaggedContent => ErrorKind::Input,
1864 Self::ExtractNeedsOcr => ErrorKind::Unsupported,
1865 Self::ExtractColumnOrderUncertain => ErrorKind::Unsupported,
1866 Self::PdfaOneAuthor => ErrorKind::Usage,
1867 Self::PdfuaTitleMissing => ErrorKind::Usage,
1868 Self::PdfaInfoMismatch => ErrorKind::Input,
1869 Self::DuplicateTagsIncomplete => ErrorKind::Usage,
1870 Self::ImportedTagsDropped => ErrorKind::Usage,
1871 Self::ImportedPdfaUnchecked => ErrorKind::Usage,
1872 Self::ImportedPdfuaUnchecked => ErrorKind::Usage,
1873 Self::AnnotWithoutContents => ErrorKind::Usage,
1874 Self::AnnotNotTagged => ErrorKind::Usage,
1875 Self::FieldLabelMissing => ErrorKind::Usage,
1876 Self::PdfaAnnotFlags => ErrorKind::Usage,
1877 Self::PdfaTransparency => ErrorKind::Usage,
1878 Self::PdfaFontNotEmbedded => ErrorKind::Usage,
1879 Self::FlattenUntagged => ErrorKind::Usage,
1880 Self::FigureWithoutAlt => ErrorKind::Usage,
1881 Self::ContentTagsBroken => ErrorKind::Input,
1882 Self::PdfaAttachmentForbidden => ErrorKind::Usage,
1883 Self::PdfaAttachmentIncomplete => ErrorKind::Usage,
1884 Self::PdfaColorSpace => ErrorKind::Usage,
1885 Self::PdfaOptionalContent => ErrorKind::Usage,
1886 Self::FieldFormattingRemoved => ErrorKind::Usage,
1887 Self::XfaOnlyContentRemoved => ErrorKind::Usage,
1888 Self::ConformanceClaimRemoved => ErrorKind::Usage,
1889 Self::RedactionMarksKept => ErrorKind::Usage,
1890 Self::HiddenContentKept => ErrorKind::Unsupported,
1891 Self::TounicodeConflict => ErrorKind::Usage,
1892 Self::WholeFontRebuilt => ErrorKind::Usage,
1893 Self::FlowKeepBroken => ErrorKind::Usage,
1894 Self::MarkdownHtmlIgnored => ErrorKind::Unsupported,
1895 Self::MarkdownImageMissing => ErrorKind::Usage,
1896 Self::InterchangeSkipped => ErrorKind::Unsupported,
1897 Self::InterchangeDocumentMismatch => ErrorKind::Input,
1898 Self::CoveredText => ErrorKind::Security,
1899 Self::RedactionNotApplied => ErrorKind::Security,
1900 Self::TextInEarlierRevision => ErrorKind::Security,
1901 Self::RichTextSimplified => ErrorKind::Usage,
1902 Self::FlattenNoAppearance => ErrorKind::Unsupported,
1903 Self::AttachmentStillHeld => ErrorKind::Usage,
1904 Self::XfaRemoved => ErrorKind::Unsupported,
1905 Self::FieldNameStillUsed => ErrorKind::Usage,
1906 Self::FieldScriptReplaced => ErrorKind::Usage,
1907 Self::SummaryPageNotDrawn => ErrorKind::Unsupported,
1908 }
1909 }
1910
1911 #[must_use]
1915 pub const fn summary(self) -> &'static str {
1916 match self {
1917 Self::MissingHeader => "no %PDF-x.y header in the first 1,024 bytes; parsing went ahead",
1918 Self::XrefRepaired => "the stored cross-reference data was unusable and was rebuilt by scanning",
1919 Self::XrefstmIgnored => "a hybrid file's /XRefStm could not be read and was ignored",
1920 Self::StreamLengthRecovered => "a stream's /Length was wrong, so its end was found by scanning for endstream",
1921 Self::DictionaryKeySkipped => "a dictionary had something other than a name where a key belongs, and it was skipped",
1922 Self::StaleGeneration => "a reference's generation did not match its xref entry, so it resolved to null",
1923 Self::PageTreeNodeSkipped => "a page-tree node was missing, malformed or too deep, and was skipped",
1924 Self::PageCountMismatch => "the page tree's /Count differs from the number of pages walked",
1925 Self::FlateTruncated => "Flate data was truncated or had a bad checksum; the partial output was kept",
1926 Self::FilterCharactersSkipped => "ASCIIHex or ASCII85 data held characters outside the filter's alphabet; they were skipped",
1927 Self::ObjstmIndexMismatch => "an object stream's index was stale and the object was found by searching",
1928 Self::ObjectNumberOutOfRange => "an xref entry above max_object_number was dropped",
1929 Self::AesPaddingInvalid => "AES-encrypted data had a bad length or padding and was kept as stored",
1930 Self::PermsMismatch => "an R5/R6 document's /Perms does not match its /P and /EncryptMetadata",
1931 Self::WarningsTruncated => "more than max_warnings warnings were raised and the rest were dropped",
1932 Self::InvalidBox => "a page boundary box is not four numbers and reads as absent",
1933 Self::InvalidRotate => "a page's /Rotate is not a multiple of 90 and reads as 0",
1934 Self::NameTreeNodeSkipped => "a name- or number-tree node was malformed, repeated or too deep, and was skipped",
1935 Self::OutlineCycle => "an outline item was reached twice; that branch of the walk stopped",
1936 Self::OutlineItemSkipped => "an outline item was missing, not a dictionary or too deep, and was skipped with its subtree",
1937 Self::InvalidDate => "an Info date is not a valid PDF date; the raw string is kept",
1938 Self::XmpInvalid => "the XMP metadata packet is not readable XMP and reads as absent",
1939 Self::AnnotNameDuplicate => "two annotations on one page have the same name (/NM), which should be unique on its page",
1940 Self::XmpRepaired => "the XMP metadata packet had damage other readers read past, and was read the same way",
1941 Self::InvalidPageLabel => "a /PageLabels entry is malformed; the malformed part is dropped",
1942 Self::InvalidEntry => "an entry a view reads is unreadable or of the wrong type and reads as absent",
1943 Self::ContentUnknownOperator => "an operator the spec does not define was skipped outside a BX/EX section",
1944 Self::ContentBadOperands => "an operator had too few operands or operands of the wrong type, or extra ones",
1945 Self::ContentUnbalancedQ => "a Q without a matching q was ignored, or saved graphics states were left open",
1946 Self::ContentUnbalancedBt => "a text object was opened twice, closed outside one, or left open",
1947 Self::ContentUnbalancedMarked => "an EMC without a matching BMC or BDC was ignored, or marked content was left open",
1948 Self::ContentSyntax => "content-stream bytes that are not a token were skipped",
1949 Self::ContentResourceMissing => "an operator named a resource that is missing, of the wrong type or unreadable",
1950 Self::InlineImageUnterminated => "no EI ends an inline image; the rest of the content was skipped",
1951 Self::XobjectCycle => "a Form XObject draws itself, directly or through other forms",
1952 Self::ContentPathUnpainted => "a content stream ended with a path no painting operator ended",
1953 Self::FontInvalid => "a font dictionary has a missing or malformed entry, so its text was decoded with defaults",
1954 Self::CmapInvalid => "a font's CMap or ToUnicode CMap is malformed or names a predefined CMap Lamina PDF has no table for",
1955 Self::UnmappedGlyph => "a font shows glyphs that nothing maps to text",
1956 Self::ExtractLimitBlocks => "a page had more runs of text than the extraction block limit; the runs past it were left out",
1957 Self::ExtractReadingOrderAmbiguous => "a page mixes horizontal and vertical writing, so the order of its blocks is a guess",
1958 Self::ExtractTableAmbiguous => "a table's rules marked out merged cells that aren't rectangles, so its cells were kept unmerged",
1959 Self::ExtractTableLimit => "a page's ruling lines would make a table bigger than the extraction's cell limit; those lines gave no table",
1960 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",
1961 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",
1962 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",
1963 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",
1964 Self::PdfaOneAuthor => "the file claims PDF/A-1, which allows one author, and its metadata lists more",
1965 Self::PdfuaTitleMissing => "the file claims PDF/UA-1, which requires a title in its metadata, and it has none",
1966 Self::PdfaInfoMismatch => "the file claims PDF/A, which requires the Info dictionary and the XMP packet to agree, and they differ",
1967 Self::DuplicateTagsIncomplete => "a duplicated page's content is partly untagged, which breaks the PDF/UA claim of the document's metadata",
1968 Self::ImportedTagsDropped => "pages copied in from another document came without their tags, which breaks the PDF/UA claim of the document's metadata",
1969 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",
1970 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",
1971 Self::AnnotWithoutContents => "a new or changed annotation has no description, which breaks the document's PDF/UA claim",
1972 Self::AnnotNotTagged => "a new annotation isn't in the structure tree, which breaks the document's PDF/UA claim",
1973 Self::FieldLabelMissing => "a new form field has no label for screen readers, which breaks the document's PDF/UA claim",
1974 Self::PdfaAnnotFlags => "an annotation doesn't print or is hidden, which breaks the document's PDF/A claim",
1975 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",
1976 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",
1977 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",
1978 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",
1979 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",
1980 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",
1981 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",
1982 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",
1983 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",
1984 Self::FieldFormattingRemoved => "a sanitise removed form fields' format and keystroke scripts with the rest of the active content, so their values no longer format as typed",
1985 Self::XfaOnlyContentRemoved => "a sanitise removed an XFA form that had no AcroForm fields to fall back on, so the form no longer shows as it did",
1986 Self::ConformanceClaimRemoved => "a sanitise removed the XMP metadata and with it the file's PDF/A or PDF/UA claim",
1987 Self::RedactionMarksKept => "a sanitise kept redaction marks that were never applied, so the text under them is still in the file",
1988 Self::HiddenContentKept => "a sanitise left hidden content in place: this build edits no page content, so it couldn't remove layers that are off, content outside the page or hidden text",
1989 Self::TounicodeConflict => "one glyph was used for two different texts; ToUnicode keeps the first",
1990 Self::WholeFontRebuilt => "a font that forbids subsetting was rebuilt with every glyph kept",
1991 Self::FlowKeepBroken => "blocks kept together are taller than a page, so the flow split them",
1992 Self::MarkdownHtmlIgnored => "the Markdown holds raw HTML, which the PDF leaves out",
1993 Self::MarkdownImageMissing => "the Markdown names an image that wasn't supplied, so the PDF leaves it out",
1994 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",
1995 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",
1996 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",
1997 Self::RedactionNotApplied => "a page has redaction marks that were never applied, so the text under them is still in the file",
1998 Self::TextInEarlierRevision => "an earlier revision of the file holds text that the latest revision no longer has",
1999 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",
2000 Self::FlattenNoAppearance => "flattening left some annotations in place: they have no appearance, and Lamina PDF can't draw one for their kind",
2001 Self::AttachmentStillHeld => "a deleted attachment stays in the document because a file attachment annotation still holds it",
2002 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",
2003 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",
2004 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",
2005 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",
2006 }
2007 }
2008
2009 #[must_use]
2013 pub const fn hint(self) -> &'static str {
2014 match self {
2015 Self::MissingHeader => "nothing to do if the document reads correctly; open in strict mode to refuse such files",
2016 Self::XrefRepaired => "check the result; save with a full rewrite, since an incremental update refuses a repaired base",
2017 Self::XrefstmIgnored => "nothing to do; the classic xref table is used instead",
2018 Self::StreamLengthRecovered => "nothing to do; a full rewrite writes the correct length",
2019 Self::DictionaryKeySkipped => "nothing to do if the document reads correctly; open in strict mode to refuse such files",
2020 Self::StaleGeneration => "nothing to do; the reference is treated as missing",
2021 Self::PageTreeNodeSkipped => "check the page count: pages under the skipped node are missing",
2022 Self::PageCountMismatch => "nothing to do; Lamina PDF uses the walked page count",
2023 Self::FlateTruncated => "check the affected content: the end of the stream may be missing",
2024 Self::FilterCharactersSkipped => "check the affected content: the stream is damaged, and what decoded may differ from what was written",
2025 Self::ObjstmIndexMismatch => "nothing to do; a full rewrite writes a correct index",
2026 Self::ObjectNumberOutOfRange => "raise max_object_number in Limits only if you trust the input",
2027 Self::AesPaddingInvalid => "treat the affected strings and streams as suspect: they may have been tampered with",
2028 Self::PermsMismatch => "treat the document's permissions as untrusted",
2029 Self::WarningsTruncated => "raise max_warnings in Limits if you need the full list",
2030 Self::InvalidBox => "nothing to do; the page uses the next box in the fallback chain",
2031 Self::InvalidRotate => "set the page rotation explicitly if 0 is wrong",
2032 Self::NameTreeNodeSkipped => "check the tree's entries: those under the skipped node are missing",
2033 Self::OutlineCycle => "nothing to do; the outline is read without the loop",
2034 Self::OutlineItemSkipped => "check the outline: the skipped item and its children are missing",
2035 Self::InvalidDate => "read the raw value from the Info view if you need it",
2036 Self::XmpInvalid => "nothing to do; a metadata edit asks before replacing it",
2037 Self::AnnotNameDuplicate => "nothing to do; both are kept, and annotations are told apart by their own IDs",
2038 Self::XmpRepaired => "nothing to do; a metadata edit writes the declarations the packet left out",
2039 Self::InvalidPageLabel => "nothing to do; affected pages fall back to decimal labels",
2040 Self::InvalidEntry => "nothing to do; the view uses the entry's default",
2041 Self::ContentUnknownOperator => "nothing to do; check the page's rendering if the operator mattered",
2042 Self::ContentBadOperands => "nothing to do; the operator was skipped or used its last operands",
2043 Self::ContentUnbalancedQ => "nothing to do; the graphics state was restored as the spec intends",
2044 Self::ContentUnbalancedBt => "nothing to do; text operators outside a text object were handled tolerantly",
2045 Self::ContentUnbalancedMarked => "check tagged-content results: marked-content sequences were closed for you",
2046 Self::ContentSyntax => "check the page's content: the bytes around the reported offset were skipped",
2047 Self::ContentResourceMissing => "check the page's resources: the operator ran without the resource or was skipped",
2048 Self::InlineImageUnterminated => "check the page's content: everything after the inline image is missing",
2049 Self::XobjectCycle => "nothing to do; the inner Do was skipped",
2050 Self::ContentPathUnpainted => "nothing to do; the unpainted path was dropped as the spec intends",
2051 Self::FontInvalid => "nothing to do; extracted text or positions for that font may be off",
2052 Self::CmapInvalid => "nothing to do; the bad entries were skipped and the rest of the CMap is used",
2053 Self::UnmappedGlyph => "nothing to do; those glyphs extract as U+FFFD (the file needs a ToUnicode CMap)",
2054 Self::ExtractLimitBlocks => "raise ExtractLimits::max_blocks_per_page if the page really has that many blocks",
2055 Self::ExtractReadingOrderAmbiguous => "nothing to do; check the order of that page's blocks, or ask for content order",
2056 Self::ExtractTableAmbiguous => "nothing to do; check that table's cells, whose text may be split across neighbours",
2057 Self::ExtractTableLimit => "raise ExtractLimits::max_table_cells if the page really has a table that big",
2058 Self::ExtractStructTreeIgnored => "nothing to do; ReadingOrder::Tagged uses the tree anyway",
2059 Self::ExtractUntaggedContent => "nothing to do; tag that text in the file to give it a place in the reading order",
2060 Self::ExtractNeedsOcr => "run OCR or a vision model on this page; the page's textLayer in the JSON says which case it is",
2061 Self::ExtractColumnOrderUncertain => "check the page, or send it to a layout model; the warning's reason says which guess was made",
2062 Self::PdfaOneAuthor => "keep one author (join the names into one), or save knowing the file no longer meets PDF/A-1",
2063 Self::PdfuaTitleMissing => "give the document a title before saving, or save knowing the file no longer meets PDF/UA-1",
2064 Self::PdfaInfoMismatch => "edit the metadata with setMetadata, which writes both, or remove the Info entries that differ",
2065 Self::DuplicateTagsIncomplete => "retag the copy, or duplicate pages whose tagged elements lie on the page alone",
2066 Self::ImportedTagsDropped => "tag the copied pages in a tagging tool, or copy pages from a document without tags",
2067 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",
2068 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",
2069 Self::AnnotWithoutContents => "give the annotation a description: the text it marks, or what the mark means",
2070 Self::AnnotNotTagged => "tag the document first, or add the annotation to a copy that doesn't claim PDF/UA",
2071 Self::FieldLabelMissing => "give the field a tooltip: the name a screen reader says",
2072 Self::PdfaAnnotFlags => "keep the annotation's Print flag and clear Hidden, Invisible, NoView and ToggleNoView",
2073 Self::PdfaTransparency => "make the mark or object opaque, use an image without transparency, or use an underline instead of a highlight",
2074 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",
2075 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",
2076 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)",
2077 Self::ContentTagsBroken => "undo the edit, or save without the PDF/UA claim (removeConformanceClaims) and tag the page again with an accessibility tool",
2078 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",
2079 Self::PdfaAttachmentIncomplete => "attach the file to the document, a page or an annotation, with its modification date and MIME type",
2080 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)",
2081 Self::PdfaOptionalContent => "add the mark without hideable, or save without the PDF/A claim (removeConformanceClaims)",
2082 Self::FieldFormattingRemoved => "tell the person; fill those fields with values already formatted, or keep the active content",
2083 Self::XfaOnlyContentRemoved => "keep the active content to keep the form, or convert the form before sanitising",
2084 Self::ConformanceClaimRemoved => "keep the metadata if the file must keep its claim, or say the file no longer claims conformance",
2085 Self::RedactionMarksKept => "apply the redactions first, then sanitise",
2086 Self::HiddenContentKept => "sanitise in a build that edits content (the default Rust build, or the SDK with the extract or text module loaded); check the file with laminapdf reveal",
2087 Self::TounicodeConflict => "mark the second occurrence with /ActualText so extraction gets its text",
2088 Self::WholeFontRebuilt => "check that the font's licence allows this, or use a static TrueType or CFF version",
2089 Self::FlowKeepBroken => "split the keep group or drop keep-with-next on a heading chain, or use a taller page",
2090 Self::MarkdownHtmlIgnored => "write the content in Markdown instead of HTML, or remove the HTML",
2091 Self::MarkdownImageMissing => "pass the image's bytes with MarkdownBuildOptions::with_image under the path the Markdown uses",
2092 Self::InterchangeSkipped => "nothing to do: the rest of the file is imported; form data is imported with the form tools",
2093 Self::InterchangeDocumentMismatch => "check that the file belongs to this document before importing it",
2094 Self::CoveredText => "remove the text itself with a tool that deletes what a redaction covers, then save a full rewrite",
2095 Self::RedactionNotApplied => "apply the redactions in a tool that removes what they cover, then save a full rewrite",
2096 Self::TextInEarlierRevision => "save the file as a full rewrite, which keeps only the latest revision",
2097 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",
2098 Self::FlattenNoAppearance => "nothing to do if they should stay; otherwise give them an appearance in the app that made them, or delete them",
2099 Self::AttachmentStillHeld => "delete the annotation too to take the file out of the document",
2100 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",
2101 Self::FieldNameStillUsed => "change the list or the calculation that still names the field or the group",
2102 Self::FieldScriptReplaced => "nothing to do if the helper call is what you meant; undo the change to keep the script",
2103 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",
2104 }
2105 }
2106
2107 #[must_use]
2111 pub fn docs_url(self) -> String {
2112 format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
2113 }
2114}