Struct html2pdf::Options

source ·
pub struct Options {
    pub input: PathBuf,
    pub output: Option<PathBuf>,
    pub landscape: bool,
    pub background: bool,
    pub wait: Option<Duration>,
    pub header: Option<String>,
    pub footer: Option<String>,
    pub paper: Option<PaperSize>,
    pub scale: Option<f64>,
    pub range: Option<String>,
    pub margin: Option<Margin>,
    pub disable_sandbox: bool,
}
Expand description

Generate a PDF from a local HTML file using a headless chrome

Fields§

§input: PathBuf

Input HTML file.

§output: Option<PathBuf>

Output file. By default, just change the input extension to PDF

§landscape: bool

Use landscape mode.

§background: bool

Allow print background.

§wait: Option<Duration>

Time to wait in ms before printing. Examples: 150ms, 10s

§header: Option<String>

HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: date for formatted print date, title for document title, url for document location, pageNumber for current page number, totalPages for total pages in the document. For example, <span class=title></span> would generate span containing the title.

§footer: Option<String>

HTML template for the print footer. Should use the same format as the headerTemplate.

§paper: Option<PaperSize>

Paper size. Supported values: A4, Letter, A3, Tabloid, A2, A1, A0, A5, A6

§scale: Option<f64>

Scale, default to 1.0

§range: Option<String>

Paper ranges to print, e.g. ‘1-5, 8, 11-13’

§margin: Option<Margin>

Margin in inches You can define margin like this: ‘0.4’ the value is applied for all side, ‘0.4 0.4’ : first value is applied for top and bottom, second for left and right, ‘0.4 0.4 0.4 0.4’ : first value is applied for top then, right, then bottom, and last for left

§disable_sandbox: bool

Disable Chrome sandbox Not recommended, unless running on docker

Implementations§

source§

impl Options

source

pub fn input(&self) -> &PathBuf

Get a reference to the cli options’s input.

source

pub fn output(&self) -> Option<&PathBuf>

Get a reference to the cli options’s output.

source

pub fn landscape(&self) -> bool

Get a reference to the cli options’s landscape.

source

pub fn background(&self) -> bool

Get a reference to the cli options’s background.

source

pub fn wait(&self) -> Option<Duration>

Get a reference to the cli options’s wait.

source

pub fn header(&self) -> Option<&String>

Get a reference to the cli options’s header.

source

pub fn footer(&self) -> Option<&String>

Get a reference to the cli options’s footer.

source

pub fn paper(&self) -> Option<&PaperSize>

Get a reference to the cli options’s paper.

source

pub fn scale(&self) -> Option<f64>

Get a reference to the cli options’s scale.

source

pub fn margin(&self) -> Option<&Margin>

Get a reference to the cli options’s margin.

source

pub fn range(&self) -> Option<&String>

Get a reference to the cli options’s range.

source

pub fn disable_sandbox(&self) -> bool

Get a reference to the cli options’s sandbox.

Trait Implementations§

source§

impl Args for Options

source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self. Read more
source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can update self. Read more
source§

impl CommandFactory for Options

source§

fn command<'b>() -> Command

Build a Command that can instantiate Self. Read more
source§

fn command_for_update<'b>() -> Command

Build a Command that can update self. Read more
source§

impl Debug for Options

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&Options> for LaunchOptions<'_>

source§

fn from(opt: &Options) -> Self

Converts to this type from the input type.
source§

impl From<&Options> for PrintToPdfOptions

source§

fn from(opt: &Options) -> Self

Converts to this type from the input type.
source§

impl FromArgMatches for Options

source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches ) -> Result<(), Error>

Assign values from ArgMatches to self.
source§

impl Parser for Options

source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error.
source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error.
source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error.
source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V