Struct 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 via FromArgMatches::from_arg_matches_mut Read more
Source§

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

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut 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. Read more
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,