pub struct HeaderFooter { /* private fields */ }Expand description
A header or footer that can be added to PDF pages.
Implementations§
Sourcepub fn new_header(content: impl Into<String>) -> Self
pub fn new_header(content: impl Into<String>) -> Self
Creates a new header with the given content.
§Example
use oxidize_pdf::text::{HeaderFooter, HeaderFooterOptions};
let header = HeaderFooter::new_header("Annual Report {{year}}");Creates a new footer with the given content.
§Example
use oxidize_pdf::text::{HeaderFooter, HeaderFooterOptions};
let footer = HeaderFooter::new_footer("Page {{page_number}} of {{total_pages}}");Sourcepub fn with_options(self, options: HeaderFooterOptions) -> Self
pub fn with_options(self, options: HeaderFooterOptions) -> Self
Sets the options for this header/footer.
Sourcepub fn with_alignment(self, alignment: TextAlign) -> Self
pub fn with_alignment(self, alignment: TextAlign) -> Self
Sets the text alignment.
Sourcepub fn with_margin(self, margin: f64) -> Self
pub fn with_margin(self, margin: f64) -> Self
Sets the margin from the page edge.
Sourcepub fn position(&self) -> HeaderFooterPosition
pub fn position(&self) -> HeaderFooterPosition
Gets the position of this header/footer.
Sourcepub fn options(&self) -> &HeaderFooterOptions
pub fn options(&self) -> &HeaderFooterOptions
Gets the options.
Sourcepub fn render(
&self,
page_number: usize,
total_pages: usize,
custom_values: Option<&HashMap<String, String>>,
) -> String
pub fn render( &self, page_number: usize, total_pages: usize, custom_values: Option<&HashMap<String, String>>, ) -> String
Renders the header/footer content with placeholder substitution.
Available placeholders:
{{page_number}}- Current page number{{total_pages}}- Total number of pages{{date}}- Current date{{time}}- Current time{{datetime}}- Current date and time{{year}}- Current year{{month}}- Current month{{day}}- Current day
Sourcepub fn calculate_y_position(&self, page_height: f64) -> f64
pub fn calculate_y_position(&self, page_height: f64) -> f64
Calculates the Y position for rendering based on page height and position.
Sourcepub fn calculate_x_position(&self, page_width: f64, text_width: f64) -> f64
pub fn calculate_x_position(&self, page_width: f64, text_width: f64) -> f64
Calculates the X position for rendering based on page width and alignment.
Trait Implementations§
Source§fn clone(&self) -> HeaderFooter
fn clone(&self) -> HeaderFooter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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