pub struct Pdf {
pub metadata: Option<Metadata>,
pub pages: Vec<Page>,
pub options: WriteOptions,
}Expand description
A document under construction. The fields are the composition:
singleton slots are Options, pages keep the order given.
Fields§
§metadata: Option<Metadata>Document information, if any.
pages: Vec<Page>Pages, in reading order.
options: WriteOptionsFile-emission options.
Implementations§
Source§impl Pdf
impl Pdf
Sourcepub fn to_bytes(self) -> Result<Vec<u8>>
pub fn to_bytes(self) -> Result<Vec<u8>>
Serializes the document to complete PDF file bytes.
Fonts are shared document-wide: each distinct Standard14 face
gets one font object, in first-use order. Images are embedded per
page with no cross-page deduplication — the same raster drawn on
two pages is stored twice.
Sourcepub fn write_into(self, out: impl Write) -> Result<()>
pub fn write_into(self, out: impl Write) -> Result<()>
Pdf::to_bytes streaming into a std::io::Write: the same
bytes, delivered in bounded chunks instead of one buffer. Unlike
to_bytes, an error can leave a prefix of the file already written
to out. No flush is performed.
Sourcepub async fn write_into_with<S: AsyncByteSink>(self, sink: S) -> Result<S>
pub async fn write_into_with<S: AsyncByteSink>(self, sink: S) -> Result<S>
Pdf::to_bytes streaming into any AsyncByteSink — the
asynchronous twin of Pdf::write_into. An error can leave a
prefix of the file already written. Hands the sink back unflushed.