Struct TexRender

Source
pub struct TexRender { /* private fields */ }
Expand description

LaTeX-rendering command.

Creating a new rendering command usually starts by supplying a LaTeX-document, either via from_bytes or from_file. Other options can be set through the various builder methods.

Once satisfied, the render method will perform the call to the external TeX-engine and return a rendered PDF as raw bytes.

§TEXINPUTS

The search path for classes, includes or other files used in TeX can be extended using the TEXINPUTS environment variable; TexRender sets this variable when rendering. See add_texinput for details.

§Assets

Instead of adding a folder to TEXINPUTS, any sort of external file can be added as an asset. Assets are stored in a temporary folder that lives as long as the TexRender instance, the folder will automatically be added to TEXINPUTS when rendering. See the add_asset_* functions for details.

Implementations§

Source§

impl TexRender

Source

pub fn from_bytes(source: Vec<u8>) -> TexRender

Create a new tex render configuration using raw input bytes as the source file.

Source

pub fn from_file<P: AsRef<Path>>(source: P) -> Result<TexRender>

Create a new tex render configuration from an input latex file.

Source

pub fn add_asset_from_bytes<S: AsRef<OsStr>>( &mut self, filename: S, bytes: &[u8], ) -> Result<()>

Adds an asset to the texrender.

Source

pub fn add_asset_from_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Adds an assets to the texrender from a file.

§Panics

Panics if the passed-in path has no proper filename.

Source

pub fn add_texinput<P: Into<PathBuf>>(&mut self, input_path: P) -> &mut Self

Adds a path to list of texinputs.

Source

pub fn latex_mk_path<P: Into<PathBuf>>(&mut self, latex_mk_path: P) -> &mut Self

Sets the path of latexmk.

If not set, will look for latexmk on the current PATH.

Source

pub fn render(&self) -> Result<Vec<u8>, RenderingError>

Renders the given source as PDF.

Trait Implementations§

Source§

impl Debug for TexRender

Source§

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

Formats the value using the given formatter. Read more

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