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 InvalidLabelRanges,
143 Sink,
145 NotRebased,
147 SinkNotEmpty,
149 WouldInvalidateSignatures,
151 RequiresRewrite,
153 InvalidFont,
155 CollectionIndex,
157 UnknownAxis,
159 FontNotEmbeddable,
161 MissingGlyph,
163 GlyphOutOfRange,
165 UnknownFont,
167 SubsetFailed,
169 InvalidAxisValue,
171 WrongDocument,
173 InvalidFeature,
175 InvalidTextRange,
177 InvalidSpans,
179 UnsupportedLayoutOption,
181 FontMismatch,
183 EncodingFull,
185 FontNotShapable,
187 InvalidImage,
189 UnsupportedImage,
191 ImageTooLarge,
193 ImageDataLength,
195 InvalidIccProfile,
197 ColorComponents,
199 InvalidColor,
201 InvalidGeometry,
203 TextOverflow,
205 PageIndexOutOfRange,
207 UnknownDestination,
209 InvalidPageLabels,
211 TagElementNotOpen,
213 TagElementUnclosed,
215 ProfileVersionConflict,
217 MissingTitle,
219 MissingLang,
221 MissingAltText,
223 UntaggedContent,
225 HeadingLevelSkipped,
227 UnnumberedHeadingMisused,
229 InvalidStructureNesting,
231 LinkWithoutStructure,
233 LinkWithoutContents,
235 FontNotEmbedded,
237 GlyphWithoutUnicode,
239 DeviceColorWithoutOutputIntent,
241 EmbeddedFileForbidden,
243 EmbeddedFileWithoutMimeType,
245 FlowContentTooLarge,
247 FlowLayoutUnstable,
249 InvalidDocument,
251 TemplateDataMissing,
253 TemplateDataType,
255 TemplateTooLarge,
257 RenderTooLarge,
259 RenderFailed,
261 RenderBackendUnavailable,
263 ExportFailed,
265 ModelFailed,
267 ModelResultUnexpected,
269 ModelNeedsHost,
271 Cancelled,
273 JobFinished,
275 DocumentChanged,
277 RevisionIndexOutOfRange,
279 BuilderFinished,
281 Disposed,
283 InvalidArgument,
285 SourceBudgetExceeded,
287 UnknownOption,
289 InvalidCommandLine,
291 InvalidPageRange,
293 BinaryOutputToTerminal,
295 UnknownCode,
297 OverwriteRefused,
299 InputUnreadable,
301 OutputUnwritable,
303 PathOutsideRoots,
305}
306
307impl ErrorCode {
308 pub const ALL: &'static [Self] = &[
312 Self::NotPdf,
313 Self::MissingRoot,
314 Self::ReferenceCycle,
315 Self::LimitExceeded,
316 Self::Strict,
317 Self::DataPending,
318 Self::Source,
319 Self::Type,
320 Self::InvalidStructure,
321 Self::UnsetObject,
322 Self::RepairedBase,
323 Self::EncryptedBase,
324 Self::PasswordRequired,
325 Self::WrongPassword,
326 Self::UnsupportedSecurityHandler,
327 Self::UnexpectedEof,
328 Self::Syntax,
329 Self::UnsupportedFilter,
330 Self::Decompress,
331 Self::NestedTransaction,
332 Self::NoTransaction,
333 Self::UnknownPage,
334 Self::DirectPage,
335 Self::UnsupportedVersion,
336 Self::InvalidOpLog,
337 Self::SavedNotRebased,
338 Self::NoPendingSave,
339 Self::MalformedXmp,
340 Self::UnknownSource,
341 Self::OpenActionNotDestination,
342 Self::UnknownOutlineItem,
343 Self::DirectOutlineItem,
344 Self::OutlineNotASibling,
345 Self::OutlineMoveIntoItself,
346 Self::UnknownNamedDestination,
347 Self::NamedDestinationExists,
348 Self::EmptyDestinationName,
349 Self::LinkUriRefused,
350 Self::ViewNotFinite,
351 Self::XmpClaimReadOnly,
352 Self::InvalidXmpPacket,
353 Self::InvalidXmpProperty,
354 Self::NoPagesLeft,
355 Self::InvalidOp,
356 Self::UnknownAnnotation,
357 Self::AnnotationLocked,
358 Self::AnnotationNotEditable,
359 Self::InvalidLabelRanges,
360 Self::Sink,
361 Self::NotRebased,
362 Self::SinkNotEmpty,
363 Self::WouldInvalidateSignatures,
364 Self::RequiresRewrite,
365 Self::InvalidFont,
366 Self::CollectionIndex,
367 Self::UnknownAxis,
368 Self::FontNotEmbeddable,
369 Self::MissingGlyph,
370 Self::GlyphOutOfRange,
371 Self::UnknownFont,
372 Self::SubsetFailed,
373 Self::InvalidAxisValue,
374 Self::WrongDocument,
375 Self::InvalidFeature,
376 Self::InvalidTextRange,
377 Self::InvalidSpans,
378 Self::UnsupportedLayoutOption,
379 Self::FontMismatch,
380 Self::EncodingFull,
381 Self::FontNotShapable,
382 Self::InvalidImage,
383 Self::UnsupportedImage,
384 Self::ImageTooLarge,
385 Self::ImageDataLength,
386 Self::InvalidIccProfile,
387 Self::ColorComponents,
388 Self::InvalidColor,
389 Self::InvalidGeometry,
390 Self::TextOverflow,
391 Self::PageIndexOutOfRange,
392 Self::UnknownDestination,
393 Self::InvalidPageLabels,
394 Self::TagElementNotOpen,
395 Self::TagElementUnclosed,
396 Self::ProfileVersionConflict,
397 Self::MissingTitle,
398 Self::MissingLang,
399 Self::MissingAltText,
400 Self::UntaggedContent,
401 Self::HeadingLevelSkipped,
402 Self::UnnumberedHeadingMisused,
403 Self::InvalidStructureNesting,
404 Self::LinkWithoutStructure,
405 Self::LinkWithoutContents,
406 Self::FontNotEmbedded,
407 Self::GlyphWithoutUnicode,
408 Self::DeviceColorWithoutOutputIntent,
409 Self::EmbeddedFileForbidden,
410 Self::EmbeddedFileWithoutMimeType,
411 Self::FlowContentTooLarge,
412 Self::FlowLayoutUnstable,
413 Self::InvalidDocument,
414 Self::TemplateDataMissing,
415 Self::TemplateDataType,
416 Self::TemplateTooLarge,
417 Self::RenderTooLarge,
418 Self::RenderFailed,
419 Self::RenderBackendUnavailable,
420 Self::ExportFailed,
421 Self::ModelFailed,
422 Self::ModelResultUnexpected,
423 Self::ModelNeedsHost,
424 Self::Cancelled,
425 Self::JobFinished,
426 Self::DocumentChanged,
427 Self::RevisionIndexOutOfRange,
428 Self::BuilderFinished,
429 Self::Disposed,
430 Self::InvalidArgument,
431 Self::SourceBudgetExceeded,
432 Self::UnknownOption,
433 Self::InvalidCommandLine,
434 Self::InvalidPageRange,
435 Self::BinaryOutputToTerminal,
436 Self::UnknownCode,
437 Self::OverwriteRefused,
438 Self::InputUnreadable,
439 Self::OutputUnwritable,
440 Self::PathOutsideRoots,
441 ];
442
443 #[must_use]
447 pub const fn from_code(code: &str) -> Option<Self> {
448 let mut rest = Self::ALL;
449 while let [first, tail @ ..] = rest {
450 if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
451 return Some(*first);
452 }
453 rest = tail;
454 }
455 None
456 }
457
458 #[must_use]
462 pub const fn as_str(self) -> &'static str {
463 match self {
464 Self::NotPdf => "not-pdf",
465 Self::MissingRoot => "missing-root",
466 Self::ReferenceCycle => "reference-cycle",
467 Self::LimitExceeded => "limit-exceeded",
468 Self::Strict => "strict",
469 Self::DataPending => "data-pending",
470 Self::Source => "source",
471 Self::Type => "type",
472 Self::InvalidStructure => "invalid-structure",
473 Self::UnsetObject => "unset-object",
474 Self::RepairedBase => "repaired-base",
475 Self::EncryptedBase => "encrypted-base",
476 Self::PasswordRequired => "password-required",
477 Self::WrongPassword => "wrong-password",
478 Self::UnsupportedSecurityHandler => "unsupported-security-handler",
479 Self::UnexpectedEof => "unexpected-eof",
480 Self::Syntax => "syntax",
481 Self::UnsupportedFilter => "unsupported-filter",
482 Self::Decompress => "decompress",
483 Self::NestedTransaction => "nested-transaction",
484 Self::NoTransaction => "no-transaction",
485 Self::UnknownPage => "unknown-page",
486 Self::DirectPage => "direct-page",
487 Self::UnsupportedVersion => "unsupported-version",
488 Self::InvalidOpLog => "invalid-op-log",
489 Self::SavedNotRebased => "saved-not-rebased",
490 Self::NoPendingSave => "no-pending-save",
491 Self::MalformedXmp => "malformed-xmp",
492 Self::UnknownSource => "unknown-source",
493 Self::OpenActionNotDestination => "open-action-not-destination",
494 Self::UnknownOutlineItem => "unknown-outline-item",
495 Self::DirectOutlineItem => "direct-outline-item",
496 Self::OutlineNotASibling => "outline-not-a-sibling",
497 Self::OutlineMoveIntoItself => "outline-move-into-itself",
498 Self::UnknownNamedDestination => "unknown-named-destination",
499 Self::NamedDestinationExists => "named-destination-exists",
500 Self::EmptyDestinationName => "empty-destination-name",
501 Self::LinkUriRefused => "link-uri-refused",
502 Self::ViewNotFinite => "view-not-finite",
503 Self::XmpClaimReadOnly => "xmp-claim-read-only",
504 Self::InvalidXmpPacket => "invalid-xmp-packet",
505 Self::InvalidXmpProperty => "invalid-xmp-property",
506 Self::NoPagesLeft => "no-pages-left",
507 Self::InvalidOp => "invalid-op",
508 Self::UnknownAnnotation => "unknown-annotation",
509 Self::AnnotationLocked => "annotation-locked",
510 Self::AnnotationNotEditable => "annotation-not-editable",
511 Self::InvalidLabelRanges => "invalid-label-ranges",
512 Self::Sink => "sink",
513 Self::NotRebased => "not-rebased",
514 Self::SinkNotEmpty => "sink-not-empty",
515 Self::WouldInvalidateSignatures => "would-invalidate-signatures",
516 Self::RequiresRewrite => "requires-rewrite",
517 Self::InvalidFont => "invalid-font",
518 Self::CollectionIndex => "collection-index",
519 Self::UnknownAxis => "unknown-axis",
520 Self::FontNotEmbeddable => "font-not-embeddable",
521 Self::MissingGlyph => "missing-glyph",
522 Self::GlyphOutOfRange => "glyph-out-of-range",
523 Self::UnknownFont => "unknown-font",
524 Self::SubsetFailed => "subset-failed",
525 Self::InvalidAxisValue => "invalid-axis-value",
526 Self::WrongDocument => "wrong-document",
527 Self::InvalidFeature => "invalid-feature",
528 Self::InvalidTextRange => "invalid-text-range",
529 Self::InvalidSpans => "invalid-spans",
530 Self::UnsupportedLayoutOption => "unsupported-layout-option",
531 Self::FontMismatch => "font-mismatch",
532 Self::EncodingFull => "encoding-full",
533 Self::FontNotShapable => "font-not-shapable",
534 Self::InvalidImage => "invalid-image",
535 Self::UnsupportedImage => "unsupported-image",
536 Self::ImageTooLarge => "image-too-large",
537 Self::ImageDataLength => "image-data-length",
538 Self::InvalidIccProfile => "invalid-icc-profile",
539 Self::ColorComponents => "color-components",
540 Self::InvalidColor => "invalid-color",
541 Self::InvalidGeometry => "invalid-geometry",
542 Self::TextOverflow => "text-overflow",
543 Self::PageIndexOutOfRange => "page-index-out-of-range",
544 Self::UnknownDestination => "unknown-destination",
545 Self::InvalidPageLabels => "invalid-page-labels",
546 Self::TagElementNotOpen => "tag-element-not-open",
547 Self::TagElementUnclosed => "tag-element-unclosed",
548 Self::ProfileVersionConflict => "profile-version-conflict",
549 Self::MissingTitle => "missing-title",
550 Self::MissingLang => "missing-lang",
551 Self::MissingAltText => "missing-alt-text",
552 Self::UntaggedContent => "untagged-content",
553 Self::HeadingLevelSkipped => "heading-level-skipped",
554 Self::UnnumberedHeadingMisused => "unnumbered-heading-misused",
555 Self::InvalidStructureNesting => "invalid-structure-nesting",
556 Self::LinkWithoutStructure => "link-without-structure",
557 Self::LinkWithoutContents => "link-without-contents",
558 Self::FontNotEmbedded => "font-not-embedded",
559 Self::GlyphWithoutUnicode => "glyph-without-unicode",
560 Self::DeviceColorWithoutOutputIntent => "device-color-without-output-intent",
561 Self::EmbeddedFileForbidden => "embedded-file-forbidden",
562 Self::EmbeddedFileWithoutMimeType => "embedded-file-without-mime-type",
563 Self::FlowContentTooLarge => "flow-content-too-large",
564 Self::FlowLayoutUnstable => "flow-layout-unstable",
565 Self::InvalidDocument => "invalid-document",
566 Self::TemplateDataMissing => "template-data-missing",
567 Self::TemplateDataType => "template-data-type",
568 Self::TemplateTooLarge => "template-too-large",
569 Self::RenderTooLarge => "render-too-large",
570 Self::RenderFailed => "render-failed",
571 Self::RenderBackendUnavailable => "render-backend-unavailable",
572 Self::ExportFailed => "export-failed",
573 Self::ModelFailed => "model-failed",
574 Self::ModelResultUnexpected => "model-result-unexpected",
575 Self::ModelNeedsHost => "model-needs-host",
576 Self::Cancelled => "cancelled",
577 Self::JobFinished => "job-finished",
578 Self::DocumentChanged => "document-changed",
579 Self::RevisionIndexOutOfRange => "revision-index-out-of-range",
580 Self::BuilderFinished => "builder-finished",
581 Self::Disposed => "disposed",
582 Self::InvalidArgument => "invalid-argument",
583 Self::SourceBudgetExceeded => "source-budget-exceeded",
584 Self::UnknownOption => "unknown-option",
585 Self::InvalidCommandLine => "invalid-command-line",
586 Self::InvalidPageRange => "invalid-page-range",
587 Self::BinaryOutputToTerminal => "binary-output-to-terminal",
588 Self::UnknownCode => "unknown-code",
589 Self::OverwriteRefused => "overwrite-refused",
590 Self::InputUnreadable => "input-unreadable",
591 Self::OutputUnwritable => "output-unwritable",
592 Self::PathOutsideRoots => "path-outside-roots",
593 }
594 }
595
596 #[must_use]
600 pub const fn kind(self) -> ErrorKind {
601 match self {
602 Self::NotPdf => ErrorKind::Input,
603 Self::MissingRoot => ErrorKind::Input,
604 Self::ReferenceCycle => ErrorKind::Input,
605 Self::LimitExceeded => ErrorKind::Limit,
606 Self::Strict => ErrorKind::Input,
607 Self::DataPending => ErrorKind::State,
608 Self::Source => ErrorKind::Io,
609 Self::Type => ErrorKind::Input,
610 Self::InvalidStructure => ErrorKind::Input,
611 Self::UnsetObject => ErrorKind::Internal,
612 Self::RepairedBase => ErrorKind::State,
613 Self::EncryptedBase => ErrorKind::Unsupported,
614 Self::PasswordRequired => ErrorKind::Security,
615 Self::WrongPassword => ErrorKind::Security,
616 Self::UnsupportedSecurityHandler => ErrorKind::Unsupported,
617 Self::UnexpectedEof => ErrorKind::Input,
618 Self::Syntax => ErrorKind::Input,
619 Self::UnsupportedFilter => ErrorKind::Unsupported,
620 Self::Decompress => ErrorKind::Input,
621 Self::NestedTransaction => ErrorKind::State,
622 Self::NoTransaction => ErrorKind::State,
623 Self::UnknownPage => ErrorKind::Usage,
624 Self::DirectPage => ErrorKind::Unsupported,
625 Self::UnsupportedVersion => ErrorKind::Unsupported,
626 Self::InvalidOpLog => ErrorKind::Input,
627 Self::SavedNotRebased => ErrorKind::State,
628 Self::NoPendingSave => ErrorKind::State,
629 Self::MalformedXmp => ErrorKind::Input,
630 Self::UnknownSource => ErrorKind::Usage,
631 Self::OpenActionNotDestination => ErrorKind::Usage,
632 Self::UnknownOutlineItem => ErrorKind::Usage,
633 Self::DirectOutlineItem => ErrorKind::Unsupported,
634 Self::OutlineNotASibling => ErrorKind::Usage,
635 Self::OutlineMoveIntoItself => ErrorKind::Usage,
636 Self::UnknownNamedDestination => ErrorKind::Usage,
637 Self::NamedDestinationExists => ErrorKind::Usage,
638 Self::EmptyDestinationName => ErrorKind::Usage,
639 Self::LinkUriRefused => ErrorKind::Usage,
640 Self::ViewNotFinite => ErrorKind::Usage,
641 Self::XmpClaimReadOnly => ErrorKind::Usage,
642 Self::InvalidXmpPacket => ErrorKind::Input,
643 Self::InvalidXmpProperty => ErrorKind::Usage,
644 Self::NoPagesLeft => ErrorKind::Usage,
645 Self::InvalidOp => ErrorKind::Usage,
646 Self::UnknownAnnotation => ErrorKind::Usage,
647 Self::AnnotationLocked => ErrorKind::State,
648 Self::AnnotationNotEditable => ErrorKind::Unsupported,
649 Self::InvalidLabelRanges => ErrorKind::Usage,
650 Self::Sink => ErrorKind::Io,
651 Self::NotRebased => ErrorKind::State,
652 Self::SinkNotEmpty => ErrorKind::Usage,
653 Self::WouldInvalidateSignatures => ErrorKind::Security,
654 Self::RequiresRewrite => ErrorKind::State,
655 Self::InvalidFont => ErrorKind::Input,
656 Self::CollectionIndex => ErrorKind::Usage,
657 Self::UnknownAxis => ErrorKind::Usage,
658 Self::FontNotEmbeddable => ErrorKind::Usage,
659 Self::MissingGlyph => ErrorKind::Input,
660 Self::GlyphOutOfRange => ErrorKind::Usage,
661 Self::UnknownFont => ErrorKind::Usage,
662 Self::SubsetFailed => ErrorKind::Unsupported,
663 Self::InvalidAxisValue => ErrorKind::Usage,
664 Self::WrongDocument => ErrorKind::Usage,
665 Self::InvalidFeature => ErrorKind::Usage,
666 Self::InvalidTextRange => ErrorKind::Usage,
667 Self::InvalidSpans => ErrorKind::Usage,
668 Self::UnsupportedLayoutOption => ErrorKind::Unsupported,
669 Self::FontMismatch => ErrorKind::Usage,
670 Self::EncodingFull => ErrorKind::Limit,
671 Self::FontNotShapable => ErrorKind::Unsupported,
672 Self::InvalidImage => ErrorKind::Input,
673 Self::UnsupportedImage => ErrorKind::Unsupported,
674 Self::ImageTooLarge => ErrorKind::Limit,
675 Self::ImageDataLength => ErrorKind::Usage,
676 Self::InvalidIccProfile => ErrorKind::Input,
677 Self::ColorComponents => ErrorKind::Usage,
678 Self::InvalidColor => ErrorKind::Usage,
679 Self::InvalidGeometry => ErrorKind::Usage,
680 Self::TextOverflow => ErrorKind::Usage,
681 Self::PageIndexOutOfRange => ErrorKind::Usage,
682 Self::UnknownDestination => ErrorKind::Usage,
683 Self::InvalidPageLabels => ErrorKind::Usage,
684 Self::TagElementNotOpen => ErrorKind::Usage,
685 Self::TagElementUnclosed => ErrorKind::Usage,
686 Self::ProfileVersionConflict => ErrorKind::Usage,
687 Self::MissingTitle => ErrorKind::Usage,
688 Self::MissingLang => ErrorKind::Usage,
689 Self::MissingAltText => ErrorKind::Usage,
690 Self::UntaggedContent => ErrorKind::Usage,
691 Self::HeadingLevelSkipped => ErrorKind::Usage,
692 Self::UnnumberedHeadingMisused => ErrorKind::Usage,
693 Self::InvalidStructureNesting => ErrorKind::Usage,
694 Self::LinkWithoutStructure => ErrorKind::Usage,
695 Self::LinkWithoutContents => ErrorKind::Usage,
696 Self::FontNotEmbedded => ErrorKind::Usage,
697 Self::GlyphWithoutUnicode => ErrorKind::Usage,
698 Self::DeviceColorWithoutOutputIntent => ErrorKind::Usage,
699 Self::EmbeddedFileForbidden => ErrorKind::Usage,
700 Self::EmbeddedFileWithoutMimeType => ErrorKind::Usage,
701 Self::FlowContentTooLarge => ErrorKind::Usage,
702 Self::FlowLayoutUnstable => ErrorKind::Internal,
703 Self::InvalidDocument => ErrorKind::Usage,
704 Self::TemplateDataMissing => ErrorKind::Usage,
705 Self::TemplateDataType => ErrorKind::Usage,
706 Self::TemplateTooLarge => ErrorKind::Usage,
707 Self::RenderTooLarge => ErrorKind::Limit,
708 Self::RenderFailed => ErrorKind::Input,
709 Self::RenderBackendUnavailable => ErrorKind::Io,
710 Self::ExportFailed => ErrorKind::Internal,
711 Self::ModelFailed => ErrorKind::Internal,
712 Self::ModelResultUnexpected => ErrorKind::Usage,
713 Self::ModelNeedsHost => ErrorKind::Usage,
714 Self::Cancelled => ErrorKind::Cancelled,
715 Self::JobFinished => ErrorKind::State,
716 Self::DocumentChanged => ErrorKind::State,
717 Self::RevisionIndexOutOfRange => ErrorKind::Usage,
718 Self::BuilderFinished => ErrorKind::State,
719 Self::Disposed => ErrorKind::State,
720 Self::InvalidArgument => ErrorKind::Usage,
721 Self::SourceBudgetExceeded => ErrorKind::Limit,
722 Self::UnknownOption => ErrorKind::Usage,
723 Self::InvalidCommandLine => ErrorKind::Usage,
724 Self::InvalidPageRange => ErrorKind::Usage,
725 Self::BinaryOutputToTerminal => ErrorKind::Usage,
726 Self::UnknownCode => ErrorKind::Usage,
727 Self::OverwriteRefused => ErrorKind::State,
728 Self::InputUnreadable => ErrorKind::Io,
729 Self::OutputUnwritable => ErrorKind::Io,
730 Self::PathOutsideRoots => ErrorKind::Security,
731 }
732 }
733
734 #[must_use]
738 pub const fn summary(self) -> &'static str {
739 match self {
740 Self::NotPdf => "the input does not look like a PDF at all",
741 Self::MissingRoot => "no document catalog (/Root) was found, even after repair",
742 Self::ReferenceCycle => "a reference chain or the page tree loops back on itself",
743 Self::LimitExceeded => "a hard Limits value was exceeded",
744 Self::Strict => "strict mode refused something the tolerant reader would have repaired",
745 Self::DataPending => "the ByteSource has not fetched the byte ranges the call needs yet",
746 Self::Source => "the ByteSource failed to read",
747 Self::Type => "an object had a different type than the structure requires",
748 Self::InvalidStructure => "an object stream, xref section or filter parameter was malformed",
749 Self::UnsetObject => "a writer object number was reserved but never given a value",
750 Self::RepairedBase => "an incremental update was requested for a document whose xref needed repair",
751 Self::EncryptedBase => "a save of an encrypted document was requested",
752 Self::PasswordRequired => "the document is encrypted with a user password and none was given",
753 Self::WrongPassword => "the given password is neither the user nor the owner password",
754 Self::UnsupportedSecurityHandler => "the document uses a security handler Lamina PDF cannot decrypt",
755 Self::UnexpectedEof => "the input ended before a complete token or object was read",
756 Self::Syntax => "a token or structure did not match the PDF grammar",
757 Self::UnsupportedFilter => "a stream uses a filter Lamina PDF does not implement",
758 Self::Decompress => "compressed stream data was corrupt",
759 Self::NestedTransaction => "a transaction was started, or undo or redo called, while one is open",
760 Self::NoTransaction => "apply, commit or rollback was called without an open transaction",
761 Self::UnknownPage => "an op names a page the document does not have",
762 Self::DirectPage => "the page is a direct dictionary, which ops cannot edit yet",
763 Self::UnsupportedVersion => "an op log has a schema version this reader does not know",
764 Self::InvalidOpLog => "an op log does not parse: an unknown op or field, a bad value, or not JSON",
765 Self::SavedNotRebased => "the document was saved to a sink Lamina PDF cannot read back and waits for rebase",
766 Self::NoPendingSave => "rebase was called without a save waiting for it",
767 Self::MalformedXmp => "a metadata edit would replace the document's XMP packet, which can't be read, losing what it holds",
768 Self::UnknownSource => "an op or a call names a source document that was not added to the session",
769 Self::OpenActionNotDestination => "an op would replace or remove the document's open action, which is an action other than a destination",
770 Self::UnknownOutlineItem => "an outline op names a bookmark the outline does not have",
771 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",
772 Self::OutlineNotASibling => "the position names a bookmark that is not a child of the parent the op names",
773 Self::OutlineMoveIntoItself => "a move would put a bookmark inside itself or one of its descendants",
774 Self::UnknownNamedDestination => "the op names a destination the file does not define",
775 Self::NamedDestinationExists => "a rename to a name another destination already has",
776 Self::EmptyDestinationName => "a destination name is empty",
777 Self::LinkUriRefused => "a web address that isn't an absolute http, https or mailto address in plain ASCII",
778 Self::ViewNotFinite => "a destination's coordinates and zoom must be finite numbers",
779 Self::XmpClaimReadOnly => "an XMP edit would change the file's PDF/A or PDF/UA identification, which only conversion or a check may set",
780 Self::InvalidXmpPacket => "the XMP packet given to replace the document's doesn't parse",
781 Self::InvalidXmpProperty => "an XMP property edit names a property, or gives a value, that can't be written",
782 Self::NoPagesLeft => "a page deletion would leave the document with no pages",
783 Self::InvalidOp => "an op's values are out of range, such as a page count or a page size",
784 Self::UnknownAnnotation => "the op names an annotation that no page of the document lists",
785 Self::AnnotationLocked => "the annotation's flags forbid the change: Locked forbids deleting it or changing its properties, LockedContents changing its contents",
786 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",
787 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",
788 Self::Sink => "the sink failed to take the bytes or could not give them back",
789 Self::NotRebased => "the output was written, but rebasing the document onto it failed",
790 Self::SinkNotEmpty => "the sink already held bytes before the save started",
791 Self::WouldInvalidateSignatures => "the save would break one or more signatures",
792 Self::RequiresRewrite => "an incremental save was requested but only a full rewrite is safe",
793 Self::InvalidFont => "font bytes could not be read as a font",
794 Self::CollectionIndex => "a font collection member past the end of the collection was asked for",
795 Self::UnknownAxis => "an instance was asked for on a variation axis the font does not have",
796 Self::FontNotEmbeddable => "the font's OS/2 fsType forbids embedding",
797 Self::MissingGlyph => "the font has no glyph for a character of the text",
798 Self::GlyphOutOfRange => "a glyph ID at or past the font's glyph count was used",
799 Self::UnknownFont => "a FontKey was used with a registry that did not hand it out",
800 Self::SubsetFailed => "subsetting a font failed",
801 Self::InvalidAxisValue => "a variation axis value was NaN or infinite",
802 Self::WrongDocument => "finish_fonts was given a document the registry did not reserve its fonts in",
803 Self::InvalidFeature => "an OpenType feature setting did not parse",
804 Self::InvalidTextRange => "a byte range was out of bounds or not on character boundaries of the text",
805 Self::InvalidSpans => "the styled spans given for a paragraph do not cover its text once, in order",
806 Self::UnsupportedLayoutOption => "a layout option that is not implemented yet was asked for",
807 Self::FontMismatch => "a shaped run was given with a font key for a different font than it was shaped with",
808 Self::EncodingFull => "a standard 14 font has no free one-byte code left for another glyph",
809 Self::FontNotShapable => "a standard 14 font was given to shaping or layout, which need a font program",
810 Self::InvalidImage => "image bytes are not a readable image of the format they were given as",
811 Self::UnsupportedImage => "the image uses a feature that PDF or Lamina PDF does not support",
812 Self::ImageTooLarge => "the image needs more memory than the builder allows (a decoded PNG over 256 MiB, or raw dimensions whose size overflows)",
813 Self::ImageDataLength => "raw image samples are not width x height x channels bytes long",
814 Self::InvalidIccProfile => "the bytes are not a usable ICC profile",
815 Self::ColorComponents => "a colour has the wrong number of components for its colour space",
816 Self::InvalidColor => "a colour string is not of the form #rgb or #rrggbb",
817 Self::InvalidGeometry => "a page size, box, /UserUnit, drawing value (coordinate, matrix, line width, dash, miter limit) or image size is not usable",
818 Self::TextOverflow => "a text box's lines don't all fit its height and its options asked for an error",
819 Self::PageIndexOutOfRange => "a link, outline item or destination names a page index the document doesn't have",
820 Self::UnknownDestination => "a link or outline item names a destination that was never defined",
821 Self::InvalidPageLabels => "page label ranges that don't start at page 0, don't increase, start past the last page or number from 0",
822 Self::TagElementNotOpen => "a structure element resumed or closed isn't open",
823 Self::TagElementUnclosed => "structure elements opened across pages were never closed",
824 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)",
825 Self::MissingTitle => "PDF/UA-1 needs a document title, and the metadata gives none",
826 Self::MissingLang => "PDF/UA-1 needs the document's natural language, and none was set",
827 Self::MissingAltText => "a Figure or Formula has no alternate text (/Alt or /ActualText), which PDF/UA-1 requires",
828 Self::UntaggedContent => "content was drawn outside every structure element and artifact, which PDF/UA-1 forbids",
829 Self::HeadingLevelSkipped => "a heading skips a level (the first is not H1, or an H3 follows an H1), which PDF/UA-1 forbids",
830 Self::UnnumberedHeadingMisused => "an unnumbered H heading shares its parent with another H, or the document also uses H1-H6, which PDF/UA-1 forbids",
831 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)",
832 Self::LinkWithoutStructure => "a link annotation has no Link structure element (it was drawn inside an artifact), which PDF/UA-1 forbids",
833 Self::LinkWithoutContents => "a link annotation has no description (/Contents), which PDF/UA-1 requires",
834 Self::FontNotEmbedded => "a standard 14 font, which is never embedded, was used under a profile that needs every font embedded",
835 Self::GlyphWithoutUnicode => "a glyph was drawn without a Unicode value, which PDF/A-2u and PDF/UA-1 forbid",
836 Self::DeviceColorWithoutOutputIntent => "a DeviceCMYK colour or image was used, but the PDF/A output intent is sRGB",
837 Self::EmbeddedFileForbidden => "PDF/A-2 doesn't allow attached files that aren't PDF/A themselves",
838 Self::EmbeddedFileWithoutMimeType => "an attached file has no MIME type, which every PDF/A profile requires",
839 Self::FlowContentTooLarge => "a line or a figure of a flow is taller than the page's body, so no page can hold it",
840 Self::FlowLayoutUnstable => "a flow's contents page kept changing its page numbers after four layouts",
841 Self::InvalidDocument => "a laminapdf.document/1 document has an unknown key, a missing one or a value of the wrong kind",
842 Self::TemplateDataMissing => "a template's $data, $each or $item points to a value the data doesn't have",
843 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",
844 Self::TemplateTooLarge => "a template would fill in more values, or nest deeper, than a document may hold",
845 Self::RenderTooLarge => "the requested tile is larger than the render limits allow; nothing was allocated",
846 Self::RenderFailed => "the render engine could not open the document or draw the page",
847 Self::RenderBackendUnavailable => "the render engine is not available: its library or module could not be loaded",
848 Self::ExportFailed => "an export's PNG, JPEG or TIFF encoder failed on a page that was drawn",
849 Self::ModelFailed => "a layout model, OCR engine or page renderer plugged into an extraction failed; the extraction stops with no partial result",
850 Self::ModelResultUnexpected => "a model result was handed to an extraction job that hadn't asked for it, or was the other model's result",
851 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",
852 Self::Cancelled => "a CancelToken stopped the work; the job is finished and returned no partial result",
853 Self::JobFinished => "a job was stepped after it had finished, failed or been cancelled",
854 Self::DocumentChanged => "the document a job was created for changed (an edit, undo, redo, save or rebase) or a different document was passed to step",
855 Self::RevisionIndexOutOfRange => "an earlier revision was asked for by an index past the file's last revision",
856 Self::BuilderFinished => "a builder or one of its pages was used after it finished",
857 Self::Disposed => "a document, builder or other handle was used after free(), or after the using block that held it ended",
858 Self::InvalidArgument => "a value passed to a binding does not have the shape its type declares",
859 Self::SourceBudgetExceeded => "a sparse source was given more bytes than its byte budget allows",
860 Self::UnknownOption => "an options record passed to a binding has a key Lamina PDF does not know",
861 Self::InvalidCommandLine => "the command line doesn't parse: an unknown command or flag, a missing argument, a bad value, or stdin named twice",
862 Self::InvalidPageRange => "a page range doesn't fit the grammar, or names a page the document lacks",
863 Self::BinaryOutputToTerminal => "the command would write a PDF to standard output, and standard output is a terminal",
864 Self::UnknownCode => "explain was given a code that isn't a Lamina PDF error or warning code",
865 Self::OverwriteRefused => "the output file exists, or the command would modify its input in place, and --force wasn't given",
866 Self::InputUnreadable => "an input file, standard input or the password file couldn't be read",
867 Self::OutputUnwritable => "the output couldn't be written: its folder is missing or read-only, the disk is full, or standard output closed",
868 Self::PathOutsideRoots => "laminapdf mcp was given a path outside its --root folders, or a link that leads out of them",
869 }
870 }
871
872 #[must_use]
876 pub const fn hint(self) -> &'static str {
877 match self {
878 Self::NotPdf => "check that the bytes passed to open are a PDF file",
879 Self::MissingRoot => "use another copy of the file: this one has no usable catalog",
880 Self::ReferenceCycle => "use another copy of the file, or repair it with another tool",
881 Self::LimitExceeded => "the input exceeds a safety limit; raise {limit} in Limits only if you trust the input",
882 Self::Strict => "open without strict mode to read the file with repairs, or fix the file",
883 Self::DataPending => "fetch the listed ranges into the source and retry the call",
884 Self::Source => "retry the call, or check the source; the document stays usable",
885 Self::Type => "use another copy of the file, or repair it with another tool",
886 Self::InvalidStructure => "use another copy of the file, or repair it with another tool",
887 Self::UnsetObject => "this is a bug in Lamina PDF: report it with the steps that led to it",
888 Self::RepairedBase => "save with a full rewrite instead of an incremental update",
889 Self::EncryptedBase => "saving encrypted documents is not supported yet; use another tool to decrypt or re-encrypt",
890 Self::PasswordRequired => "pass the document's password in OpenOptions",
891 Self::WrongPassword => "ask for the password again and retry with the correct one",
892 Self::UnsupportedSecurityHandler => "use a tool that supports this encryption to decrypt the file first",
893 Self::UnexpectedEof => "use a complete copy of the file: this one looks truncated",
894 Self::Syntax => "use another copy of the file, or repair it with another tool",
895 Self::UnsupportedFilter => "use a tool that supports the filter to read this stream",
896 Self::Decompress => "use another copy of the file: this stream's data is damaged",
897 Self::NestedTransaction => "commit or roll back the open transaction first, or use a savepoint inside it",
898 Self::NoTransaction => "call begin first, or use transact",
899 Self::UnknownPage => "use a PageId from this document's pages()",
900 Self::DirectPage => "rewrite the file so that every page is an indirect object, or wait for page-structure ops",
901 Self::UnsupportedVersion => "upgrade Lamina PDF to a version that reads this op log version",
902 Self::InvalidOpLog => "validate the op log against the op schema; the samples in fixtures/ops show the format",
903 Self::SavedNotRebased => "call rebase with the saved bytes before applying ops or saving again",
904 Self::NoPendingSave => "call rebase only after a save that returned SavedNotRebased",
905 Self::MalformedXmp => "set replaceMalformed on the edit to replace the packet with a new one, or leave the metadata as it is",
906 Self::UnknownSource => "add the source document's bytes with addSource before applying ops that name it",
907 Self::OpenActionNotDestination => "leave the open page out of the edit, which keeps the open action as it is",
908 Self::UnknownOutlineItem => "read the outline again and use one of its item IDs; an item a previous op deleted is gone",
909 Self::DirectOutlineItem => "apply any other outline op first: it rewrites the outline and gives every bookmark an object and an ID of its own",
910 Self::OutlineNotASibling => "name a position among the parent's own children, or use first or last",
911 Self::OutlineMoveIntoItself => "choose a parent outside the bookmark's own branch",
912 Self::UnknownNamedDestination => "list the file's named destinations and use one of their names",
913 Self::NamedDestinationExists => "choose a name no destination has, or delete the other one first",
914 Self::EmptyDestinationName => "give the destination a name of at least one character",
915 Self::LinkUriRefused => "use a full address such as https://example.com/page; encode other characters with %",
916 Self::ViewNotFinite => "pass finite numbers, or null to keep the viewer's current value",
917 Self::XmpClaimReadOnly => "leave the pdfaid: and pdfuaid: properties as they are; edit the other properties, or keep them unchanged in a replaced packet",
918 Self::InvalidXmpPacket => "fix the XML at the offset in the error's data (reason says what is wrong), then replace the packet again",
919 Self::InvalidXmpProperty => "check the part the error's reason names: the namespace, prefix, name, value, or the shape a mirrored property needs",
920 Self::NoPagesLeft => "keep at least one page: delete all but one, or insert a blank page first",
921 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",
922 Self::UnknownAnnotation => "read the page's annotations again and use an ID from that list",
923 Self::AnnotationLocked => "clear the lock with an update of its flags first, if you may",
924 Self::AnnotationNotEditable => "edit a widget through its form field; an annotation stored inside the page's list can't be edited yet",
925 Self::InvalidLabelRanges => "give ranges in page order, the first on the document's first page, each numbered from 1 or more",
926 Self::Sink => "check the destination and retry the save; the document is unchanged",
927 Self::NotRebased => "retry rebase with the saved output carried by the error",
928 Self::SinkNotEmpty => "pass an empty sink: output offsets count from the sink's first byte",
929 Self::WouldInvalidateSignatures => "save with SaveMode::Auto, or ask the user and retry with SaveOptions::with_invalidate_signatures",
930 Self::RequiresRewrite => "save with SaveMode::Auto or SaveMode::FullRewrite",
931 Self::InvalidFont => "pass the complete bytes of a .ttf, .otf, .ttc or .otc file",
932 Self::CollectionIndex => "use an index below Font::collection_len",
933 Self::UnknownAxis => "check the font's axes before choosing coordinates, or use a variable font",
934 Self::FontNotEmbeddable => "use another font, or register it with EmbedPolicy::Override if your licence allows embedding",
935 Self::MissingGlyph => "use a font that covers the character, or split the text across fonts",
936 Self::GlyphOutOfRange => "pass glyph IDs from the font you registered",
937 Self::UnknownFont => "use the key returned by this registry's add",
938 Self::SubsetFailed => "try another version or format of the font, and report the font if it is a common one",
939 Self::InvalidAxisValue => "pass finite axis values; values outside the axis range are clamped",
940 Self::WrongDocument => "use one FontRegistry per document and finish it with that document",
941 Self::InvalidFeature => "write it as liga=0, -liga, smcp or aalt=2 (HarfBuzz syntax without ranges)",
942 Self::InvalidTextRange => "take ranges from Lamina PDF's results (line_breaks, itemize, break_lines) and pass the same text",
943 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",
944 Self::UnsupportedLayoutOption => "leave the option at its default; justification comes with a later release",
945 Self::FontMismatch => "pass the key of the font the run was shaped with (the font index of each line run maps to your keys)",
946 Self::EncodingFull => "embed a font with Font::from_bytes, or split the text across two registrations of the standard font",
947 Self::FontNotShapable => "draw standard 14 fonts with FontRegistry::encode, or shape with an embedded font",
948 Self::InvalidImage => "pass the complete bytes of a JPEG or PNG file to Image::jpeg or Image::png",
949 Self::UnsupportedImage => "convert it to a baseline or progressive 8-bit JPEG, or to PNG",
950 Self::ImageTooLarge => "scale the image down before adding it",
951 Self::ImageDataLength => "pass exactly 4 bytes (RGBA) per pixel, row by row",
952 Self::InvalidIccProfile => "pass a complete ICC profile with a Gray, RGB or CMYK data colour space",
953 Self::ColorComponents => "give one component per channel of the colour space (/N of the ICC profile)",
954 Self::InvalidColor => "write the colour as # followed by 3 or 6 hexadecimal digits",
955 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",
956 Self::TextOverflow => "make the box taller or the text shorter, or use Overflow::Clip and read TextLayout::overflow",
957 Self::PageIndexOutOfRange => "use a 0-based index below the document's page count",
958 Self::UnknownDestination => "define it with Builder::destination before the build finishes, or link to a page",
959 Self::InvalidPageLabels => "give ranges sorted by first page, the first at page 0, numbered from 1",
960 Self::TagElementNotOpen => "resume and close only elements this builder's pages opened with open_element, and close each once",
961 Self::TagElementUnclosed => "close each element from open_element with Builder::close_element once its last page is finished",
962 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",
963 Self::MissingTitle => "set a title with Builder::metadata (Metadata::with_title)",
964 Self::MissingLang => "set the language with Builder::lang, such as \"en-GB\"",
965 Self::MissingAltText => "give the figure or formula a description with Tag::with_alt or Surface::figure's alt, or draw decoration as an artifact",
966 Self::UntaggedContent => "draw it inside Surface::tag (real content) or Surface::artifact (decoration)",
967 Self::HeadingLevelSkipped => "start with H1 and go down one level at a time",
968 Self::UnnumberedHeadingMisused => "use numbered headings (H1, H2, ...) throughout, or one H per section",
969 Self::InvalidStructureNesting => "nest tables as Table > TR > TH/TD and lists as L > LI > Lbl/LBody",
970 Self::LinkWithoutStructure => "draw links outside artifacts, so the builder gives each one a Link element",
971 Self::LinkWithoutContents => "pass a description as the link's contents",
972 Self::FontNotEmbedded => "load a font file with Builder::font instead of Builder::standard_font",
973 Self::GlyphWithoutUnicode => "remove NUL characters (U+0000) from the text, or choose PDF/A-2b, which doesn't need Unicode",
974 Self::DeviceColorWithoutOutputIntent => "use RGB or gray colours, or a CMYK colour with an ICC profile (Color::icc)",
975 Self::EmbeddedFileForbidden => "choose PDF/A-3b, which allows attached files of any kind",
976 Self::EmbeddedFileWithoutMimeType => "pass the file's MIME type, such as text/xml or application/octet-stream",
977 Self::FlowContentTooLarge => "make the figure smaller, the text size smaller or the page's margins narrower",
978 Self::FlowLayoutUnstable => "report the flow that fails; a page break after the contents block may avoid it until it is fixed",
979 Self::InvalidDocument => "data.pointer names the value; correct it against the document schema, and didYouMean lists the closest known keys",
980 Self::TemplateDataMissing => "data.pointer names the value the template asked for; add it to the data or correct the pointer",
981 Self::TemplateDataType => "data.pointer names the value and data.expected the kind the template needs there",
982 Self::TemplateTooLarge => "data.limit is the limit it passed; repeat fewer items, or split the document",
983 Self::RenderTooLarge => "request smaller tiles (256 to 512 pixels at high zoom) or raise RenderLimits if the larger bitmap is intended",
984 Self::RenderFailed => "the file may be damaged or use a feature this engine can't draw; try the other backend, or report the file",
985 Self::RenderBackendUnavailable => "run cargo xtask fetch-pdfium or set LAMINA_PDF_PDFIUM_DIR to the folder holding the PDFium library",
986 Self::ExportFailed => "report it with the format and the page: the encoder writes into memory, so this is a bug in Lamina PDF",
987 Self::ModelFailed => "check the plug-in's own logs; extract without the model to get the rules-only result",
988 Self::ModelResultUnexpected => "call provide only while request() returns a request, with the result its kind asks for",
989 Self::ModelNeedsHost => "step an extraction job and hand it each result with provide, or give the plug-in a page renderer",
990 Self::Cancelled => "nothing to do: this is the outcome the caller asked for; start a new job to try again",
991 Self::JobFinished => "stop stepping a job once a step returned its result or an error; create a new job",
992 Self::DocumentChanged => "pass the document the job was created from, and don't change it while the job runs; create a new job",
993 Self::RevisionIndexOutOfRange => "ask for an index below the document's revision count",
994 Self::BuilderFinished => "create a new builder or page: a finished one takes no more drawing, pages, fonts or settings",
995 Self::Disposed => "free a handle only after its last use; to keep working, open the document again or create a new builder",
996 Self::InvalidArgument => "pass the value the type declarations describe; the data field says what was wrong",
997 Self::SourceBudgetExceeded => "raise the source's budget, or open the file with fewer bytes fetched (smaller blocks, no readahead)",
998 Self::UnknownOption => "remove the key or correct its spelling; didYouMean lists the closest known names",
999 Self::InvalidCommandLine => "run the command with --help to see its arguments",
1000 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",
1001 Self::BinaryOutputToTerminal => "redirect standard output to a file or a pipe, or write to a file with -o",
1002 Self::UnknownCode => "check the spelling against didYouMean, or list every code at the docs URL",
1003 Self::OverwriteRefused => "pass --force, or write to a new file with -o",
1004 Self::InputUnreadable => "check that the file exists and that you can read it; data.input names it",
1005 Self::OutputUnwritable => "check that the output's folder exists, that you can write to it and that the disk has room",
1006 Self::PathOutsideRoots => "use a path inside one of the server's --root folders, or start the server with another --root",
1007 }
1008 }
1009
1010 #[must_use]
1014 pub fn docs_url(self) -> String {
1015 format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
1016 }
1017}
1018
1019#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1023#[non_exhaustive]
1024pub enum WarningCode {
1025 MissingHeader,
1027 XrefRepaired,
1029 XrefstmIgnored,
1031 StreamLengthRecovered,
1033 StaleGeneration,
1035 PageTreeNodeSkipped,
1037 PageCountMismatch,
1039 FlateTruncated,
1041 ObjstmIndexMismatch,
1043 ObjectNumberOutOfRange,
1045 AesPaddingInvalid,
1047 PermsMismatch,
1049 WarningsTruncated,
1051 InvalidBox,
1053 InvalidRotate,
1055 NameTreeNodeSkipped,
1057 OutlineCycle,
1059 OutlineItemSkipped,
1061 InvalidDate,
1063 XmpInvalid,
1065 AnnotNameDuplicate,
1067 XmpRepaired,
1069 InvalidPageLabel,
1071 InvalidEntry,
1073 ContentUnknownOperator,
1075 ContentBadOperands,
1077 ContentUnbalancedQ,
1079 ContentUnbalancedBt,
1081 ContentUnbalancedMarked,
1083 ContentSyntax,
1085 ContentResourceMissing,
1087 InlineImageUnterminated,
1089 XobjectCycle,
1091 ContentPathUnpainted,
1093 FontInvalid,
1095 CmapInvalid,
1097 UnmappedGlyph,
1099 ExtractLimitBlocks,
1101 ExtractReadingOrderAmbiguous,
1103 ExtractTableAmbiguous,
1105 ExtractTableLimit,
1107 ExtractStructTreeIgnored,
1109 ExtractUntaggedContent,
1111 ExtractNeedsOcr,
1113 ExtractColumnOrderUncertain,
1115 PdfaOneAuthor,
1117 PdfuaTitleMissing,
1119 PdfaInfoMismatch,
1121 DuplicateTagsIncomplete,
1123 ImportedTagsDropped,
1125 ImportedPdfaUnchecked,
1127 TounicodeConflict,
1129 WholeFontRebuilt,
1131 FlowKeepBroken,
1133 MarkdownHtmlIgnored,
1135 MarkdownImageMissing,
1137 CoveredText,
1139 RedactionNotApplied,
1141 TextInEarlierRevision,
1143}
1144
1145impl WarningCode {
1146 pub const ALL: &'static [Self] = &[
1150 Self::MissingHeader,
1151 Self::XrefRepaired,
1152 Self::XrefstmIgnored,
1153 Self::StreamLengthRecovered,
1154 Self::StaleGeneration,
1155 Self::PageTreeNodeSkipped,
1156 Self::PageCountMismatch,
1157 Self::FlateTruncated,
1158 Self::ObjstmIndexMismatch,
1159 Self::ObjectNumberOutOfRange,
1160 Self::AesPaddingInvalid,
1161 Self::PermsMismatch,
1162 Self::WarningsTruncated,
1163 Self::InvalidBox,
1164 Self::InvalidRotate,
1165 Self::NameTreeNodeSkipped,
1166 Self::OutlineCycle,
1167 Self::OutlineItemSkipped,
1168 Self::InvalidDate,
1169 Self::XmpInvalid,
1170 Self::AnnotNameDuplicate,
1171 Self::XmpRepaired,
1172 Self::InvalidPageLabel,
1173 Self::InvalidEntry,
1174 Self::ContentUnknownOperator,
1175 Self::ContentBadOperands,
1176 Self::ContentUnbalancedQ,
1177 Self::ContentUnbalancedBt,
1178 Self::ContentUnbalancedMarked,
1179 Self::ContentSyntax,
1180 Self::ContentResourceMissing,
1181 Self::InlineImageUnterminated,
1182 Self::XobjectCycle,
1183 Self::ContentPathUnpainted,
1184 Self::FontInvalid,
1185 Self::CmapInvalid,
1186 Self::UnmappedGlyph,
1187 Self::ExtractLimitBlocks,
1188 Self::ExtractReadingOrderAmbiguous,
1189 Self::ExtractTableAmbiguous,
1190 Self::ExtractTableLimit,
1191 Self::ExtractStructTreeIgnored,
1192 Self::ExtractUntaggedContent,
1193 Self::ExtractNeedsOcr,
1194 Self::ExtractColumnOrderUncertain,
1195 Self::PdfaOneAuthor,
1196 Self::PdfuaTitleMissing,
1197 Self::PdfaInfoMismatch,
1198 Self::DuplicateTagsIncomplete,
1199 Self::ImportedTagsDropped,
1200 Self::ImportedPdfaUnchecked,
1201 Self::TounicodeConflict,
1202 Self::WholeFontRebuilt,
1203 Self::FlowKeepBroken,
1204 Self::MarkdownHtmlIgnored,
1205 Self::MarkdownImageMissing,
1206 Self::CoveredText,
1207 Self::RedactionNotApplied,
1208 Self::TextInEarlierRevision,
1209 ];
1210
1211 #[must_use]
1215 pub const fn from_code(code: &str) -> Option<Self> {
1216 let mut rest = Self::ALL;
1217 while let [first, tail @ ..] = rest {
1218 if bytes_eq(first.as_str().as_bytes(), code.as_bytes()) {
1219 return Some(*first);
1220 }
1221 rest = tail;
1222 }
1223 None
1224 }
1225
1226 #[must_use]
1230 pub const fn as_str(self) -> &'static str {
1231 match self {
1232 Self::MissingHeader => "missing-header",
1233 Self::XrefRepaired => "xref-repaired",
1234 Self::XrefstmIgnored => "xrefstm-ignored",
1235 Self::StreamLengthRecovered => "stream-length-recovered",
1236 Self::StaleGeneration => "stale-generation",
1237 Self::PageTreeNodeSkipped => "page-tree-node-skipped",
1238 Self::PageCountMismatch => "page-count-mismatch",
1239 Self::FlateTruncated => "flate-truncated",
1240 Self::ObjstmIndexMismatch => "objstm-index-mismatch",
1241 Self::ObjectNumberOutOfRange => "object-number-out-of-range",
1242 Self::AesPaddingInvalid => "aes-padding-invalid",
1243 Self::PermsMismatch => "perms-mismatch",
1244 Self::WarningsTruncated => "warnings-truncated",
1245 Self::InvalidBox => "invalid-box",
1246 Self::InvalidRotate => "invalid-rotate",
1247 Self::NameTreeNodeSkipped => "name-tree-node-skipped",
1248 Self::OutlineCycle => "outline-cycle",
1249 Self::OutlineItemSkipped => "outline-item-skipped",
1250 Self::InvalidDate => "invalid-date",
1251 Self::XmpInvalid => "xmp-invalid",
1252 Self::AnnotNameDuplicate => "annot-name-duplicate",
1253 Self::XmpRepaired => "xmp-repaired",
1254 Self::InvalidPageLabel => "invalid-page-label",
1255 Self::InvalidEntry => "invalid-entry",
1256 Self::ContentUnknownOperator => "content-unknown-operator",
1257 Self::ContentBadOperands => "content-bad-operands",
1258 Self::ContentUnbalancedQ => "content-unbalanced-q",
1259 Self::ContentUnbalancedBt => "content-unbalanced-bt",
1260 Self::ContentUnbalancedMarked => "content-unbalanced-marked",
1261 Self::ContentSyntax => "content-syntax",
1262 Self::ContentResourceMissing => "content-resource-missing",
1263 Self::InlineImageUnterminated => "inline-image-unterminated",
1264 Self::XobjectCycle => "xobject-cycle",
1265 Self::ContentPathUnpainted => "content-path-unpainted",
1266 Self::FontInvalid => "font-invalid",
1267 Self::CmapInvalid => "cmap-invalid",
1268 Self::UnmappedGlyph => "unmapped-glyph",
1269 Self::ExtractLimitBlocks => "extract-limit-blocks",
1270 Self::ExtractReadingOrderAmbiguous => "extract-reading-order-ambiguous",
1271 Self::ExtractTableAmbiguous => "extract-table-ambiguous",
1272 Self::ExtractTableLimit => "extract-table-limit",
1273 Self::ExtractStructTreeIgnored => "extract-struct-tree-ignored",
1274 Self::ExtractUntaggedContent => "extract-untagged-content",
1275 Self::ExtractNeedsOcr => "extract-needs-ocr",
1276 Self::ExtractColumnOrderUncertain => "extract-column-order-uncertain",
1277 Self::PdfaOneAuthor => "pdfa-one-author",
1278 Self::PdfuaTitleMissing => "pdfua-title-missing",
1279 Self::PdfaInfoMismatch => "pdfa-info-mismatch",
1280 Self::DuplicateTagsIncomplete => "duplicate-tags-incomplete",
1281 Self::ImportedTagsDropped => "imported-tags-dropped",
1282 Self::ImportedPdfaUnchecked => "imported-pdfa-unchecked",
1283 Self::TounicodeConflict => "tounicode-conflict",
1284 Self::WholeFontRebuilt => "whole-font-rebuilt",
1285 Self::FlowKeepBroken => "flow-keep-broken",
1286 Self::MarkdownHtmlIgnored => "markdown-html-ignored",
1287 Self::MarkdownImageMissing => "markdown-image-missing",
1288 Self::CoveredText => "covered-text",
1289 Self::RedactionNotApplied => "redaction-not-applied",
1290 Self::TextInEarlierRevision => "text-in-earlier-revision",
1291 }
1292 }
1293
1294 #[must_use]
1298 pub const fn kind(self) -> ErrorKind {
1299 match self {
1300 Self::MissingHeader => ErrorKind::Input,
1301 Self::XrefRepaired => ErrorKind::Input,
1302 Self::XrefstmIgnored => ErrorKind::Input,
1303 Self::StreamLengthRecovered => ErrorKind::Input,
1304 Self::StaleGeneration => ErrorKind::Input,
1305 Self::PageTreeNodeSkipped => ErrorKind::Input,
1306 Self::PageCountMismatch => ErrorKind::Input,
1307 Self::FlateTruncated => ErrorKind::Input,
1308 Self::ObjstmIndexMismatch => ErrorKind::Input,
1309 Self::ObjectNumberOutOfRange => ErrorKind::Limit,
1310 Self::AesPaddingInvalid => ErrorKind::Security,
1311 Self::PermsMismatch => ErrorKind::Security,
1312 Self::WarningsTruncated => ErrorKind::Limit,
1313 Self::InvalidBox => ErrorKind::Input,
1314 Self::InvalidRotate => ErrorKind::Input,
1315 Self::NameTreeNodeSkipped => ErrorKind::Input,
1316 Self::OutlineCycle => ErrorKind::Input,
1317 Self::OutlineItemSkipped => ErrorKind::Input,
1318 Self::InvalidDate => ErrorKind::Input,
1319 Self::XmpInvalid => ErrorKind::Input,
1320 Self::AnnotNameDuplicate => ErrorKind::Input,
1321 Self::XmpRepaired => ErrorKind::Input,
1322 Self::InvalidPageLabel => ErrorKind::Input,
1323 Self::InvalidEntry => ErrorKind::Input,
1324 Self::ContentUnknownOperator => ErrorKind::Input,
1325 Self::ContentBadOperands => ErrorKind::Input,
1326 Self::ContentUnbalancedQ => ErrorKind::Input,
1327 Self::ContentUnbalancedBt => ErrorKind::Input,
1328 Self::ContentUnbalancedMarked => ErrorKind::Input,
1329 Self::ContentSyntax => ErrorKind::Input,
1330 Self::ContentResourceMissing => ErrorKind::Input,
1331 Self::InlineImageUnterminated => ErrorKind::Input,
1332 Self::XobjectCycle => ErrorKind::Input,
1333 Self::ContentPathUnpainted => ErrorKind::Input,
1334 Self::FontInvalid => ErrorKind::Input,
1335 Self::CmapInvalid => ErrorKind::Input,
1336 Self::UnmappedGlyph => ErrorKind::Input,
1337 Self::ExtractLimitBlocks => ErrorKind::Limit,
1338 Self::ExtractReadingOrderAmbiguous => ErrorKind::Unsupported,
1339 Self::ExtractTableAmbiguous => ErrorKind::Unsupported,
1340 Self::ExtractTableLimit => ErrorKind::Limit,
1341 Self::ExtractStructTreeIgnored => ErrorKind::Input,
1342 Self::ExtractUntaggedContent => ErrorKind::Input,
1343 Self::ExtractNeedsOcr => ErrorKind::Unsupported,
1344 Self::ExtractColumnOrderUncertain => ErrorKind::Unsupported,
1345 Self::PdfaOneAuthor => ErrorKind::Usage,
1346 Self::PdfuaTitleMissing => ErrorKind::Usage,
1347 Self::PdfaInfoMismatch => ErrorKind::Input,
1348 Self::DuplicateTagsIncomplete => ErrorKind::Usage,
1349 Self::ImportedTagsDropped => ErrorKind::Usage,
1350 Self::ImportedPdfaUnchecked => ErrorKind::Usage,
1351 Self::TounicodeConflict => ErrorKind::Usage,
1352 Self::WholeFontRebuilt => ErrorKind::Usage,
1353 Self::FlowKeepBroken => ErrorKind::Usage,
1354 Self::MarkdownHtmlIgnored => ErrorKind::Unsupported,
1355 Self::MarkdownImageMissing => ErrorKind::Usage,
1356 Self::CoveredText => ErrorKind::Security,
1357 Self::RedactionNotApplied => ErrorKind::Security,
1358 Self::TextInEarlierRevision => ErrorKind::Security,
1359 }
1360 }
1361
1362 #[must_use]
1366 pub const fn summary(self) -> &'static str {
1367 match self {
1368 Self::MissingHeader => "no %PDF-x.y header in the first 1,024 bytes; parsing went ahead",
1369 Self::XrefRepaired => "the stored cross-reference data was unusable and was rebuilt by scanning",
1370 Self::XrefstmIgnored => "a hybrid file's /XRefStm could not be read and was ignored",
1371 Self::StreamLengthRecovered => "a stream's /Length was wrong, so its end was found by scanning for endstream",
1372 Self::StaleGeneration => "a reference's generation did not match its xref entry, so it resolved to null",
1373 Self::PageTreeNodeSkipped => "a page-tree node was missing, malformed or too deep, and was skipped",
1374 Self::PageCountMismatch => "the page tree's /Count differs from the number of pages walked",
1375 Self::FlateTruncated => "Flate data was truncated or had a bad checksum; the partial output was kept",
1376 Self::ObjstmIndexMismatch => "an object stream's index was stale and the object was found by searching",
1377 Self::ObjectNumberOutOfRange => "an xref entry above max_object_number was dropped",
1378 Self::AesPaddingInvalid => "AES-encrypted data had a bad length or padding and was kept as stored",
1379 Self::PermsMismatch => "an R5/R6 document's /Perms does not match its /P and /EncryptMetadata",
1380 Self::WarningsTruncated => "more than max_warnings warnings were raised and the rest were dropped",
1381 Self::InvalidBox => "a page boundary box is not four numbers and reads as absent",
1382 Self::InvalidRotate => "a page's /Rotate is not a multiple of 90 and reads as 0",
1383 Self::NameTreeNodeSkipped => "a name- or number-tree node was malformed, repeated or too deep, and was skipped",
1384 Self::OutlineCycle => "an outline item was reached twice; that branch of the walk stopped",
1385 Self::OutlineItemSkipped => "an outline item was missing, not a dictionary or too deep, and was skipped with its subtree",
1386 Self::InvalidDate => "an Info date is not a valid PDF date; the raw string is kept",
1387 Self::XmpInvalid => "the XMP metadata packet is not readable XMP and reads as absent",
1388 Self::AnnotNameDuplicate => "two annotations on one page have the same name (/NM), which should be unique on its page",
1389 Self::XmpRepaired => "the XMP metadata packet had damage other readers read past, and was read the same way",
1390 Self::InvalidPageLabel => "a /PageLabels entry is malformed; the malformed part is dropped",
1391 Self::InvalidEntry => "an entry a view reads is unreadable or of the wrong type and reads as absent",
1392 Self::ContentUnknownOperator => "an operator the spec does not define was skipped outside a BX/EX section",
1393 Self::ContentBadOperands => "an operator had too few operands or operands of the wrong type, or extra ones",
1394 Self::ContentUnbalancedQ => "a Q without a matching q was ignored, or saved graphics states were left open",
1395 Self::ContentUnbalancedBt => "a text object was opened twice, closed outside one, or left open",
1396 Self::ContentUnbalancedMarked => "an EMC without a matching BMC or BDC was ignored, or marked content was left open",
1397 Self::ContentSyntax => "content-stream bytes that are not a token were skipped",
1398 Self::ContentResourceMissing => "an operator named a resource that is missing, of the wrong type or unreadable",
1399 Self::InlineImageUnterminated => "no EI ends an inline image; the rest of the content was skipped",
1400 Self::XobjectCycle => "a Form XObject draws itself, directly or through other forms",
1401 Self::ContentPathUnpainted => "a content stream ended with a path no painting operator ended",
1402 Self::FontInvalid => "a font dictionary has a missing or malformed entry, so its text was decoded with defaults",
1403 Self::CmapInvalid => "a font's CMap or ToUnicode CMap is malformed or names a predefined CMap Lamina PDF has no table for",
1404 Self::UnmappedGlyph => "a font shows glyphs that nothing maps to text",
1405 Self::ExtractLimitBlocks => "a page had more runs of text than the extraction block limit; the runs past it were left out",
1406 Self::ExtractReadingOrderAmbiguous => "a page mixes horizontal and vertical writing, so the order of its blocks is a guess",
1407 Self::ExtractTableAmbiguous => "a table's rules marked out merged cells that aren't rectangles, so its cells were kept unmerged",
1408 Self::ExtractTableLimit => "a page's ruling lines would make a table bigger than the extraction's cell limit; those lines gave no table",
1409 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",
1410 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",
1411 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",
1412 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",
1413 Self::PdfaOneAuthor => "the file claims PDF/A-1, which allows one author, and its metadata lists more",
1414 Self::PdfuaTitleMissing => "the file claims PDF/UA-1, which requires a title in its metadata, and it has none",
1415 Self::PdfaInfoMismatch => "the file claims PDF/A, which requires the Info dictionary and the XMP packet to agree, and they differ",
1416 Self::DuplicateTagsIncomplete => "a duplicated page's content is partly untagged, which breaks the PDF/UA claim of the document's metadata",
1417 Self::ImportedTagsDropped => "pages copied in from another document came without their tags, which breaks the PDF/UA claim of the document's metadata",
1418 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",
1419 Self::TounicodeConflict => "one glyph was used for two different texts; ToUnicode keeps the first",
1420 Self::WholeFontRebuilt => "a font that forbids subsetting was rebuilt with every glyph kept",
1421 Self::FlowKeepBroken => "blocks kept together are taller than a page, so the flow split them",
1422 Self::MarkdownHtmlIgnored => "the Markdown holds raw HTML, which the PDF leaves out",
1423 Self::MarkdownImageMissing => "the Markdown names an image that wasn't supplied, so the PDF leaves it out",
1424 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",
1425 Self::RedactionNotApplied => "a page has redaction marks that were never applied, so the text under them is still in the file",
1426 Self::TextInEarlierRevision => "an earlier revision of the file holds text that the latest revision no longer has",
1427 }
1428 }
1429
1430 #[must_use]
1434 pub const fn hint(self) -> &'static str {
1435 match self {
1436 Self::MissingHeader => "nothing to do if the document reads correctly; open in strict mode to refuse such files",
1437 Self::XrefRepaired => "check the result; save with a full rewrite, since an incremental update refuses a repaired base",
1438 Self::XrefstmIgnored => "nothing to do; the classic xref table is used instead",
1439 Self::StreamLengthRecovered => "nothing to do; a full rewrite writes the correct length",
1440 Self::StaleGeneration => "nothing to do; the reference is treated as missing",
1441 Self::PageTreeNodeSkipped => "check the page count: pages under the skipped node are missing",
1442 Self::PageCountMismatch => "nothing to do; Lamina PDF uses the walked page count",
1443 Self::FlateTruncated => "check the affected content: the end of the stream may be missing",
1444 Self::ObjstmIndexMismatch => "nothing to do; a full rewrite writes a correct index",
1445 Self::ObjectNumberOutOfRange => "raise max_object_number in Limits only if you trust the input",
1446 Self::AesPaddingInvalid => "treat the affected strings and streams as suspect: they may have been tampered with",
1447 Self::PermsMismatch => "treat the document's permissions as untrusted",
1448 Self::WarningsTruncated => "raise max_warnings in Limits if you need the full list",
1449 Self::InvalidBox => "nothing to do; the page uses the next box in the fallback chain",
1450 Self::InvalidRotate => "set the page rotation explicitly if 0 is wrong",
1451 Self::NameTreeNodeSkipped => "check the tree's entries: those under the skipped node are missing",
1452 Self::OutlineCycle => "nothing to do; the outline is read without the loop",
1453 Self::OutlineItemSkipped => "check the outline: the skipped item and its children are missing",
1454 Self::InvalidDate => "read the raw value from the Info view if you need it",
1455 Self::XmpInvalid => "nothing to do; a metadata edit asks before replacing it",
1456 Self::AnnotNameDuplicate => "nothing to do; both are kept, and annotations are told apart by their own IDs",
1457 Self::XmpRepaired => "nothing to do; a metadata edit writes the declarations the packet left out",
1458 Self::InvalidPageLabel => "nothing to do; affected pages fall back to decimal labels",
1459 Self::InvalidEntry => "nothing to do; the view uses the entry's default",
1460 Self::ContentUnknownOperator => "nothing to do; check the page's rendering if the operator mattered",
1461 Self::ContentBadOperands => "nothing to do; the operator was skipped or used its last operands",
1462 Self::ContentUnbalancedQ => "nothing to do; the graphics state was restored as the spec intends",
1463 Self::ContentUnbalancedBt => "nothing to do; text operators outside a text object were handled tolerantly",
1464 Self::ContentUnbalancedMarked => "check tagged-content results: marked-content sequences were closed for you",
1465 Self::ContentSyntax => "check the page's content: the bytes around the reported offset were skipped",
1466 Self::ContentResourceMissing => "check the page's resources: the operator ran without the resource or was skipped",
1467 Self::InlineImageUnterminated => "check the page's content: everything after the inline image is missing",
1468 Self::XobjectCycle => "nothing to do; the inner Do was skipped",
1469 Self::ContentPathUnpainted => "nothing to do; the unpainted path was dropped as the spec intends",
1470 Self::FontInvalid => "nothing to do; extracted text or positions for that font may be off",
1471 Self::CmapInvalid => "nothing to do; the bad entries were skipped and the rest of the CMap is used",
1472 Self::UnmappedGlyph => "nothing to do; those glyphs extract as U+FFFD (the file needs a ToUnicode CMap)",
1473 Self::ExtractLimitBlocks => "raise ExtractLimits::max_blocks_per_page if the page really has that many blocks",
1474 Self::ExtractReadingOrderAmbiguous => "nothing to do; check the order of that page's blocks, or ask for content order",
1475 Self::ExtractTableAmbiguous => "nothing to do; check that table's cells, whose text may be split across neighbours",
1476 Self::ExtractTableLimit => "raise ExtractLimits::max_table_cells if the page really has a table that big",
1477 Self::ExtractStructTreeIgnored => "nothing to do; ReadingOrder::Tagged uses the tree anyway",
1478 Self::ExtractUntaggedContent => "nothing to do; tag that text in the file to give it a place in the reading order",
1479 Self::ExtractNeedsOcr => "run OCR or a vision model on this page; the page's textLayer in the JSON says which case it is",
1480 Self::ExtractColumnOrderUncertain => "check the page, or send it to a layout model; the warning's reason says which guess was made",
1481 Self::PdfaOneAuthor => "keep one author (join the names into one), or save knowing the file no longer meets PDF/A-1",
1482 Self::PdfuaTitleMissing => "give the document a title before saving, or save knowing the file no longer meets PDF/UA-1",
1483 Self::PdfaInfoMismatch => "edit the metadata with setMetadata, which writes both, or remove the Info entries that differ",
1484 Self::DuplicateTagsIncomplete => "retag the copy, or duplicate pages whose tagged elements lie on the page alone",
1485 Self::ImportedTagsDropped => "tag the copied pages in a tagging tool, or copy pages from a document without tags",
1486 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",
1487 Self::TounicodeConflict => "mark the second occurrence with /ActualText so extraction gets its text",
1488 Self::WholeFontRebuilt => "check that the font's licence allows this, or use a static TrueType or CFF version",
1489 Self::FlowKeepBroken => "split the keep group or drop keep-with-next on a heading chain, or use a taller page",
1490 Self::MarkdownHtmlIgnored => "write the content in Markdown instead of HTML, or remove the HTML",
1491 Self::MarkdownImageMissing => "pass the image's bytes with MarkdownBuildOptions::with_image under the path the Markdown uses",
1492 Self::CoveredText => "remove the text itself with a tool that deletes what a redaction covers, then save a full rewrite",
1493 Self::RedactionNotApplied => "apply the redactions in a tool that removes what they cover, then save a full rewrite",
1494 Self::TextInEarlierRevision => "save the file as a full rewrite, which keeps only the latest revision",
1495 }
1496 }
1497
1498 #[must_use]
1502 pub fn docs_url(self) -> String {
1503 format!("{DOCS_URL_BASE}{}{DOCS_URL_SUFFIX}", self.as_str())
1504 }
1505}