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