Expand description
Platform-neutral, bounded I/O contracts for CAJ-family conversion.
Format implementations are separate from these contracts. A source must
expose a stable size and positioned reads; the output is any
std::io::Write, which receives bytes in order. Forward-only input must
be spooled by a platform adapter or rejected explicitly.
Modules§
- arith
- Scaffolding shared by the T.82 QM decoder (
crate::qm) and the T.88 MQ decoder (crate::jbig2::mq): the context bank, the coded span, the register snapshot, and the symbol counters. Each decoder keeps its own interval arithmetic and probability states and reads its coded bytes from aPayloadin memory. - bundled_
fonts - Shared defaults for versioned native-text font resources. Versioned CAJViewer font resource facts and measured native-text presets. Adapters supply the bytes; the core never downloads or opens files.
- caj
- Checked metadata reader for the observed
CAJ\0container variant. - hnc8
- Bounded metadata traversal for the three independently measured HN/C8
container profiles. Image payloads and text are never loaded here.
convert_document_pdfandconvert_source_pages_pdfconvert whole documents; type-0, JPEG and type-3 images are checked and emitted by the one shared composition pipeline. Composition validates the observed text frame while retaining only raw image-coordinate words. Empirical geometry remains diagnostic.Hnc8Reader::application_inforeads the trailing C8 application-info package’s DOI, URL and note count. - jbig1
- Bounded CAJ-family type-0 rows using the standard T.82 probability states.
- jbig2
- Bounded T.88 JBIG2 segment framing and arithmetic model primitives.
- kdh
- Ranged KDH decoding over the PDF input and repair layer.
- native
- A positioned source over a
std::iohandle. - Bounded PDF input, fragment repair, and forward-only PDF 1.7 output.
- qm
- Experimental, bounded T.82 arithmetic decoder for an already isolated SCD.
Structs§
- Bookmark
- One outline entry in document order.
- Conversion
Options - What
convertproduces from a document. - Conversion
Report - Counters and warnings from a completed conversion.
- Counting
Source - A
RangedSourceadapter that adds each count its source returns to a caller-owned byte counter. - Detection
- A recognized input family and where its header starts.
- Document
Info - Bounded summary returned by
inspect. - Error
- A failure visible to native and JavaScript callers: what went wrong, the absolute input offset and the structure it was found in, when known, and a fixed description.
- Fonts
- Font resources for native HN/C8 text.
- Image
Counts - Images drawn by an HN/C8 conversion, by codec.
- Inspect
Options - What
inspectreads besides the summary. - Limits
- Resource limits applied before allocation and during I/O.
- Never
Cancel - A cancellation signal for operations that cannot be cancelled.
- Omitted
Page - A page whose content was replaced by an explicit blank page.
- Payload
- Bytes read into memory, with the source offset of their first byte.
Enums§
- Context
- The structure a failure was located in.
- Error
Kind - What went wrong.
- Hnc8
Stage - The HN/C8 conversion stage a failure arose in.
- Input
Format - Recognized input families. Recognition does not imply conversion support.
- Structure
- Structure-only document facts; never document text.
- Type3
Stage - The type-3 image decoding stage a failure arose in.
Constants§
- DEFAULT_
IO_ CHUNK - Default payload per read or write call: 256 KiB.
- FONTS_
REQUIRE_ HNC8 - The reason of the error
convertreturns whenFontsare given for a document other than HN or C8. - MAX_
IO_ CHUNK - Hard payload ceiling per read or write call: 1 MiB.
- PDF_
HEADER_ SEARCH_ BYTES - Leading bytes searched for a
%PDF-header that does not start at byte 0. The whole five-byte marker must lie within this prefix. - SIGNATURE_
BYTES - Leading bytes that
detect_formatneeds to recognize every signature that must start at byte 0.
Traits§
- Bookmark
Visitor - A recipient for streamed bookmark entries, called once per entry.
- Cancellation
- A platform-provided cancellation signal, checked between rows, pages and I/O chunks.
- Page
Visitor - A recipient for
inspect_pages. An error it returns ends the report and is returned as it is. - Progress
- What a facade operation tells its caller while it runs, and how the
caller stops it. Every method has a default;
NeverCanceluses them all. - Ranged
Source - A source with a stable size snapshot and positioned reads.
Functions§
- convert
- Convert one document to PDF bytes written to
sink. - convert_
with_ ttkn_ response - Convert the measured TTKN server-auth PDF profile using an explicit response.
No authentication endpoint is contacted. The response is case-sensitive and
is never included in errors. Other TTKN profiles remain unsupported.
Atomic-output requirements are the same as for
convert. - detect_
format - Recognize an input family from its leading bytes, never from a file name:
some observed
.cajfiles are plain PDFs. - detect_
source - Read the leading bytes of
sourceand recognize its input family asdetect_formatdoes, also locating a displaced PDF header. - index_
pdf - Index a PDF, whose
%PDF-header may follow leading bytes, forcrate::pdf::PdfOutlineAppender. Any other family is refused as bysuper::convert, afterProgress::formatnames it. - inspect
- Read bounded document metadata without writing or decoding any page.
- inspect_
pages - Stream one structural record per page of the HN/C8 document that
info(frominspect) describes; image payloads and text content are never reported. Returnsfalsewithout callingvisitorwhen the family has no per-page records. - native_
font_ mode - Native rendering mode when the input needs fonts, otherwise
None. Uses the same bounded routing asneeds_fonts; does not read fonts. - needs_
fonts - Whether
convertwould draw native text for this input and therefore needsFonts: an HN or C8 document thatcrate::hnc8::uses_native_textroutes to native composition. Other families, and empty or unrecognized inputs, need none; converting them reports their own errors. Only a failed read or cancellation is an error.Progress::formatis not called. - read_
exact_ at - Fill one bounded buffer from a positioned source, tolerating short reads.
- read_
outline - The outline of a CAJ document, for an outline import. Any other family
is refused as by
super::convert, afterProgress::formatnames it. - read_
payload - Read
lengthbytes atoffsetintobuffer, replacing its contents, in requests of at most one I/O chunk. The length must fitlimits.max_allocation_bytes; the buffer is reused between payloads.