InterpreterSettings

Struct InterpreterSettings 

Source
pub struct InterpreterSettings {
    pub font_resolver: FontResolverFn,
    pub warning_sink: WarningSinkFn,
    pub render_annotations: bool,
}
Expand description

Settings that should be applied during the interpretation process.

Fields§

§font_resolver: FontResolverFn

Nearly every PDF contains text. In most cases, PDF files embed the fonts they use, and hayro can therefore read the font files and do all the processing needed. However, there are two problems:

  • Fonts don’t have to be embedded, it’s possible that the PDF file only defines the basic metadata of the font, like its name, but relies on the PDF processor to find that font in its environment.
  • The PDF specification requires a list of 14 fonts that should always be available to a PDF processor. These include:
    • Times New Roman (Normal, Bold, Italic, BoldItalic)
    • Courier (Normal, Bold, Italic, BoldItalic)
    • Helvetica (Normal, Bold, Italic, BoldItalic)
    • ZapfDingBats
    • Symbol

Because of this, if any of the above situations occurs, this callback will be called, which expects the data of an appropriate font to be returned, if available. If no such font is provided, the text will most likely fail to render.

For the font data, there are two different formats that are accepted:

  • Any valid TTF/OTF font.
  • A valid CFF font program.

The following recommendations are given for the implementation of this callback function.

For the standard fonts, in case the original fonts are available on the system, you should just return those. Otherwise, for Helvetica, Courier and Times New Roman, the best alternative are the corresponding fonts of the Liberation font family. If you prefer smaller fonts, you can use the Foxit CFF fonts, which are much smaller but are missing glyphs for certain scripts.

For the Symbol and ZapfDingBats fonts, you should also prefer the system fonts, and if not available to you, you can, similarly to above, use the corresponding fonts from Foxit.

If you don’t want having to deal with this, you can just enable the embed-fonts feature and use the default implementation of the callback.

§warning_sink: WarningSinkFn

In certain cases, hayro will emit a warning in case an issue was encountered while interpreting the PDF file. Providing a callback allows you to catch those warnings and handle them, if desired.

§render_annotations: bool

Whether annotations should be rendered as well.

Note that this feature is currently not fully implemented yet, so some annotations might be missing.

Trait Implementations§

Source§

impl Clone for InterpreterSettings

Source§

fn clone(&self) -> InterpreterSettings

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for InterpreterSettings

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> ErasedDestructor for T
where T: 'static,