Skip to main content

build_pdf

Function build_pdf 

Source
pub fn build_pdf(
    graph: &PageGraph,
    metadata: &PdfMetadata,
) -> Result<(Vec<u8>, Vec<Diagnostic>)>
Expand description

Build PDF bytes in memory without accessing the filesystem.

Returns the same bytes and encoding diagnostics as emit, including MOS0032 for Base14 extended-glyph budget exhaustion. Layout diagnostics remain in mos_layout::LayoutResult::diagnostics. The caller owns the returned bytes and can write, upload, or serve them as needed.

§Errors

Returns an error if embedded font subsetting fails.

§Examples

use mos_layout::PageGraph;
use mos_pdf::{PdfMetadata, build_pdf};

let (bytes, diagnostics) = build_pdf(&PageGraph::default(), &PdfMetadata::default())?;
assert!(bytes.starts_with(b"%PDF-"));
assert!(diagnostics.is_empty());