Skip to main content

encode_document_pdf_split

Function encode_document_pdf_split 

Source
pub fn encode_document_pdf_split(
    images: &[Array2<u8>],
    config: &Jbig2Config,
) -> Result<PdfSplitOutput, Jbig2Error>
Expand description

Encodes a multi-page document for PDF embedding, sharing one symbol dictionary across every page.

PDF readers expect multi-page JBIG2 content as a single JBIG2Globals object (the shared symbol dictionary) referenced by each page’s separate /JBIG2Decode stream. Producing that layout requires every page to be planned and serialized by the same encoder instance so that the symbol indices referenced by each page’s text regions line up with the shared dictionary’s symbol table — building the dictionary and the page streams from independent encoders silently desyncs those indices and produces undecodable pages (solid black/white, decoder errors, etc.).

§Arguments

  • images - the page images, in document order
  • config - encoder configuration; symbol_mode controls whether a shared global dictionary is produced at all (when disabled, every page is encoded as an independent generic region and global_segments is None)

§Returns

A PdfSplitOutput with the optional global dictionary segment plus one page stream per input image, ready to embed directly.