pub struct DocumentBuilder { /* private fields */ }Expand description
High-level builder for creating multi-page PDF documents with automatic layout.
Wraps FlowLayout with an owned-chaining API so you can build a complete
document in a single expression.
§Example
use oxidize_pdf::layout::DocumentBuilder;
use oxidize_pdf::Font;
let mut doc = DocumentBuilder::a4()
.add_text("Invoice #001", Font::HelveticaBold, 18.0)
.add_spacer(10.0)
.add_text("Date: 2026-04-09", Font::Helvetica, 12.0)
.build()
.unwrap();
doc.save("invoice.pdf").unwrap();Implementations§
Source§impl DocumentBuilder
impl DocumentBuilder
Sourcepub fn new(config: PageConfig) -> Self
pub fn new(config: PageConfig) -> Self
Create a builder with custom page configuration.
Sourcepub fn add_text(self, text: &str, font: Font, font_size: f64) -> Self
pub fn add_text(self, text: &str, font: Font, font_size: f64) -> Self
Add a text block with default line height (1.2).
Sourcepub fn add_text_with_line_height(
self,
text: &str,
font: Font,
font_size: f64,
line_height: f64,
) -> Self
pub fn add_text_with_line_height( self, text: &str, font: Font, font_size: f64, line_height: f64, ) -> Self
Add a text block with custom line height.
Sourcepub fn add_spacer(self, points: f64) -> Self
pub fn add_spacer(self, points: f64) -> Self
Add vertical spacing in points.
Sourcepub fn add_image(
self,
name: &str,
image: Arc<Image>,
max_width: f64,
max_height: f64,
) -> Self
pub fn add_image( self, name: &str, image: Arc<Image>, max_width: f64, max_height: f64, ) -> Self
Add an image scaled to fit within max dimensions, left-aligned.
Sourcepub fn add_image_centered(
self,
name: &str,
image: Arc<Image>,
max_width: f64,
max_height: f64,
) -> Self
pub fn add_image_centered( self, name: &str, image: Arc<Image>, max_width: f64, max_height: f64, ) -> Self
Add an image scaled to fit, centered horizontally.
Sourcepub fn add_rich_text(self, rich: RichText) -> Self
pub fn add_rich_text(self, rich: RichText) -> Self
Add a single line of mixed-style text.
Auto Trait Implementations§
impl Freeze for DocumentBuilder
impl RefUnwindSafe for DocumentBuilder
impl Send for DocumentBuilder
impl Sync for DocumentBuilder
impl Unpin for DocumentBuilder
impl UnsafeUnpin for DocumentBuilder
impl UnwindSafe for DocumentBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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