Skip to main content

PdfWriter

Struct PdfWriter 

Source
pub struct PdfWriter;

Implementations§

Source§

impl PdfWriter

Source

pub fn new() -> Self

Source

pub fn write( &self, pages: &[LayoutPage], metadata: &Metadata, font_context: &FontContext, tagged: bool, pdfa: Option<&PdfAConformance>, pdf_ua: bool, embedded_data: Option<&str>, attachments: &[Attachment], zugferd: Option<&ZugferdMeta>, flatten_forms: bool, ) -> Result<(Vec<u8>, Vec<String>), FormeError>

Write laid-out pages to a PDF byte vector.

MEMORY NOTE (streaming-serialize investigation, 2026-09 — set aside): the large-document peak (~1GB for a 500-page doc) is NOT here. It is the Vec<LayoutPage> the caller retains (~2MB/page) while this fn borrows it as a slice. This writer is already ~90% streaming-ready: Pass 1 (below) consumes and zlib-compresses everything heavy per page; Pass 2 touches only scalars (width/height) and the lightweight collected lists (annotations, bookmarks). So making write take pages by value and drop each page’s elements after Pass 1 saves nothing on its own — layout() has already materialized the whole tree before write is called. A real peak reduction needs a restartable STREAMING LAYOUT producer (yield page N, serialize, drop), which collides with the sentinel count pass (total page count is needed before page 1 can emit) and touches pagination. Crucially, PDF/A + PDF/UA are NOT a blocker: the structure tree (tagged::TagBuilder), link_slots, and disjoint page/annotation StructParent numbering are a few MB of lightweight metadata that stay whole-document and assemble unchanged at finalize — so streaming frees layout memory earlier without moving a single output byte, and veraPDF stays 9/9 by construction. See scripts/parity/benchmarks.mjs trackedFixes for the full write-up.

Trait Implementations§

Source§

impl Default for PdfWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V