pub struct PdfWriter {
pub objects: Vec<(u32, PdfObject)>,
pub version: (u8, u8),
/* private fields */
}Expand description
Low-level PDF writer that accumulates indirect objects and serializes them into a valid PDF byte stream.
Fields§
§objects: Vec<(u32, PdfObject)>Stored indirect objects: (object number, object).
version: (u8, u8)PDF version as (major, minor), e.g. (1, 7).
Implementations§
Source§impl PdfWriter
impl PdfWriter
Sourcepub fn alloc_object_num(&mut self) -> u32
pub fn alloc_object_num(&mut self) -> u32
Allocate the next object number without adding an object. Useful for forward references.
Sourcepub fn add_object(&mut self, obj: PdfObject) -> IndirectRef
pub fn add_object(&mut self, obj: PdfObject) -> IndirectRef
Add an object, assigning it the next available object number.
Returns an IndirectRef that can be used to reference this object.
Sourcepub fn set_object(&mut self, obj_num: u32, obj: PdfObject)
pub fn set_object(&mut self, obj_num: u32, obj: PdfObject)
Set (or replace) an object at a specific object number. If an object with this number already exists, it is replaced.
Sourcepub fn write_to_bytes(&self, catalog_ref: &IndirectRef) -> Result<Vec<u8>>
pub fn write_to_bytes(&self, catalog_ref: &IndirectRef) -> Result<Vec<u8>>
Serialize all objects into a complete PDF byte stream.
Sourcepub fn write_to_file(
&self,
path: &Path,
catalog_ref: &IndirectRef,
) -> Result<()>
pub fn write_to_file( &self, path: &Path, catalog_ref: &IndirectRef, ) -> Result<()>
Serialize and write to a file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PdfWriter
impl RefUnwindSafe for PdfWriter
impl Send for PdfWriter
impl Sync for PdfWriter
impl Unpin for PdfWriter
impl UnsafeUnpin for PdfWriter
impl UnwindSafe for PdfWriter
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more