Skip to main content

Writer

Struct Writer 

Source
pub struct Writer {
Show 22 fields pub b: BasicPdfWriter, pub p: Page, pub fonts: FontFamily, pub cur_font: usize, pub font_size: Px, pub sup: Px, pub mode: Mode, pub title: String, pub pages: Vec<Page>, pub new_page: bool, pub line_pad: Px, pub margin_left: Px, pub margin_right: Px, pub margin_top: Px, pub margin_bottom: Px, pub page_width: Px, pub page_height: Px, pub line_used: MPx, pub line: Vec<Item>, pub max_font_size: Px, pub center: bool, pub fetcher: Option<Box<dyn Fetcher>>,
}
Expand description

Writer - has support for wrapping text, page layout, fonts, etc.

Fields§

§b: BasicPdfWriter

Underlying Basic Writer

§p: Page

Current Page

§fonts: FontFamily

List of fonts

§cur_font: usize

Index into fonts

§font_size: Px

Current font size, default is 10

§sup: Px

Current sup ( raises text up off line ), use set_sup to adjust it

§mode: Mode

Writing mode

§title: String

PDF title

§pages: Vec<Page>

List of Pages

§new_page: bool

Page is new ( not yet initialised )

§line_pad: Px

Line padding ( space between lines ) default is 4

§margin_left: Px

Line margin ( left ), default is 20

§margin_right: Px

Line margin ( right ), default is 20

§margin_top: Px

Top margin, default is 20

§margin_bottom: Px

Bottom margin, default is 20

§page_width: Px

Page width, default is 600

§page_height: Px

Page height, default is 800

§line_used: MPx

Line used ( controls word-wrapping )

§line: Vec<Item>

Line items

§max_font_size: Px

Largest font for current line

§center: bool

Default is zero, set to 1 to center output lines

§fetcher: Option<Box<dyn Fetcher>>

For fetching fonts and images

Implementations§

Source§

impl Writer

Source

pub fn save_page(&mut self)

Completes current page.

Source

pub fn output_line(&mut self)

Outputs current line ( consisting of items ).

Source

pub fn text(&mut self, s: &str)

Writes word-wrapped text if mode is Normal, adds text to title if mode is Title.

Source

pub fn image(&mut self, src: &str, awidth: Option<Px>, aheight: Option<Px>)

Write image

Source

pub fn space(&mut self)

Adds a space to text.

Source

pub fn set_sup(&mut self, sup: Px)

Sets sup

Source

pub fn finish(&mut self) -> &[u8]

Flushes output line, writes page footers, saves pages, sets title, returns finished PDF as byte slice.

Trait Implementations§

Source§

impl Default for Writer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl !RefUnwindSafe for Writer

§

impl !Send for Writer

§

impl !Sync for Writer

§

impl Unpin for Writer

§

impl UnsafeUnpin for Writer

§

impl !UnwindSafe for Writer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.