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