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§
- Clip
Path - A clip path.
- Context
- A context for interpreting PDF files.
- Function
- A PDF function.
- Interpreter
Settings - Settings that should be applied during the interpretation process.
- Luma
Data - A structure holding 1-channel luma data.
- Raster
Image - A raster image.
- RgbData
- A structure holding 3-channel RGB data.
- Soft
Mask - A soft mask.
- Stencil
Image - A stencil image.
- Stroke
Props - Stroke properties.
- Transfer
Function - A transfer function to apply to the opacity values of a mask.
Enums§
- Blend
Mode - A blend mode.
- Fill
Rule - A fill rule.
- Glyph
Draw Mode - The draw mode that should be used for a glyph.
- Image
- A type of image.
- Interpreter
Warning - Warnings that can occur while interpreting a PDF file.
- Mask
Type - Type type of mask.
- Paint
- A type of paint.
- Path
Draw Mode - The draw mode that should be used for a path.
Traits§
- Cache
Key - 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
opsand render them into the device. - interpret_
page - interpret the contents of the page and render them into the device.
Type Aliases§
- Font
Resolver Fn - A callback function for resolving font queries.
- Warning
Sink Fn - A callback function for resolving warnings during interpretation.