Skip to main content

convert_bytes

Function convert_bytes 

Source
pub fn convert_bytes(
    data: &[u8],
    file_name: &str,
    config: &ProcessingConfig,
) -> Result<PdfDocument, EdgePdfError>
Expand description

Convert a PDF from an in-memory byte slice to structured data.

This is the WASM-compatible entry point. It replaces filesystem I/O with in-memory equivalents. Embedded Image XObject tables are recovered via pdf::inmem_raster when raster_table_ocr is enabled (no pdfimages / pdftoppm). Heading hierarchy matches native convert.

Implemented as assemble so the sync path stays identical to the two-phase WASM session.

§Arguments

  • data — raw PDF bytes (e.g., from a Uint8Array in JavaScript)
  • file_name — display name (used in PdfDocument.file_name)
  • config — processing configuration

§Returns

Structured document or error.

§Errors

Returns an error if the PDF cannot be parsed or processed.