Crate hayro_interpret

Crate hayro_interpret 

Source
Expand description

A crate for interpreting PDF files.

This crate provides an abstraction to interpret the content of a PDF file and render them into an abstract Device, which clients can implement as needed. This allows you, for example, to render PDF files to bitmaps (which is what the hayro crate does), or other formats such as SVG.

It should be noted that this crate is still very much in development. Therefore it currently lacks pretty much any documentation on how to use it. It’s current API also only really makes it useful for rendering to PNG or SVG, though this will be improved upon in the future.

§Examples

See the examples folder on the GitHub repository. Apart from that, you can also consult the implementation of hayro and hayro-svg to get an idea on how to use this crate.

§Safety

This crate forbids unsafe code via a crate-level attribute.

§Cargo features

This crate has one optional feature:

  • embed-fonts: PDF processors are required to support 14 predefined fonts that do not need to be embedded into a PDF file. If you enable this feature, hayro will embed a (permissively-licensed) substitute for each font, so that you don’t have to implement your custom font loading logic. This will add around ~240KB to your binary.

Re-exports§

pub use util::PageExt;
pub use util::RectExt;
pub use hayro_syntax;

Modules§

color
PDF colors and color spaces.
encode
Encoding shading patterns for easy sampling.
font
Interacting with the different kinds of PDF fonts.
pattern
PDF patterns.
shading
PDF shadings.
util
A number of utility methods.

Structs§

ClipPath
A clip path.
Context
A context for interpreting PDF files.
Function
A PDF function.
InterpreterSettings
Settings that should be applied during the interpretation process.
LumaData
A structure holding 1-channel luma data.
RasterImage
A raster image.
RgbData
A structure holding 3-channel RGB data.
SoftMask
A soft mask.
StencilImage
A stencil image.
StrokeProps
Stroke properties.
TransferFunction
A transfer function to apply to the opacity values of a mask.

Enums§

BlendMode
A blend mode.
FillRule
A fill rule.
GlyphDrawMode
The draw mode that should be used for a glyph.
Image
A type of image.
InterpreterWarning
Warnings that can occur while interpreting a PDF file.
MaskType
Type type of mask.
Paint
A type of paint.
PathDrawMode
The draw mode that should be used for a path.

Traits§

CacheKey
A trait for objects that can generate a unique cache key.
Device
A trait for a device that can be used to process PDF drawing instructions.

Functions§

interpret
Interpret the instructions from ops and render them into the device.
interpret_page
interpret the contents of the page and render them into the device.

Type Aliases§

FontResolverFn
A callback function for resolving font queries.
WarningSinkFn
A callback function for resolving warnings during interpretation.