pub struct StreamingPdfRenderer { /* private fields */ }Expand description
Streaming PDF renderer that builds documents incrementally
Unlike the standard PdfRenderer which requires the full area tree, this renderer accepts pages one at a time and can generate PDF output incrementally to minimize memory usage.
Implementations§
Source§impl StreamingPdfRenderer
impl StreamingPdfRenderer
Sourcepub fn add_page(&mut self, area_tree: &AreaTree) -> Result<()>
pub fn add_page(&mut self, area_tree: &AreaTree) -> Result<()>
Add a single page from an area tree to the PDF
This method processes one page at a time. After this call returns, the area_tree can be dropped to free memory.
§Arguments
area_tree- Area tree containing exactly one page
§Returns
Returns Ok(()) if the page was successfully added, or an error otherwise.
Sourcepub fn write_to<W: Write>(self, writer: &mut W) -> Result<()>
pub fn write_to<W: Write>(self, writer: &mut W) -> Result<()>
Write the PDF to an output stream
This finalizes the PDF document and writes all data to the output stream. After this call, no more pages can be added.
Sourcepub fn to_bytes(self) -> Result<Vec<u8>>
pub fn to_bytes(self) -> Result<Vec<u8>>
Get the bytes of the PDF document
This finalizes the PDF document and returns all bytes. After this call, no more pages can be added.
Sourcepub fn page_count(&self) -> usize
pub fn page_count(&self) -> usize
Get the number of pages added so far
Set the PDF document author
Sourcepub fn set_subject(&mut self, subject: String)
pub fn set_subject(&mut self, subject: String)
Set the PDF document subject
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StreamingPdfRenderer
impl RefUnwindSafe for StreamingPdfRenderer
impl Send for StreamingPdfRenderer
impl Sync for StreamingPdfRenderer
impl Unpin for StreamingPdfRenderer
impl UnsafeUnpin for StreamingPdfRenderer
impl UnwindSafe for StreamingPdfRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().