/pdf

Library library to read (and possibly modify and write) PDF files.

Primary LanguageRust

pdf-rs Build Status

Read, alter and write PDF files.

At the moment, you can only read PDF files.

One easy way you can contribute is to add different PDF files to tests/files and see if they pass the tests (cargo test).

Feel free to contribute with ideas, issues or code! Please join us on Zulip if you have any questions or problems.

Building

The PDF standard references 14 standard fonts, which are not distributed with it. Due to dubious practices by Adobe, it is not safe to publish them in the viewer.

You can download them here and unpack with

tar -xf fonts.tar.bz

placing the fonts directory in repository directory.

Finally set the environment variable STANDARD_FONTS to the fonts folder:

export STANDARD_FONTS=$pwd/fonts

Alternativly you can run ./download_fonts.sh to get them from this old debian release of the Adobe PDF reader. And AdobePiStd.ttf can be found on the internet as well:

Over all you will need in the fonts directory:

  • CourierStd.otf
  • CourierStd-Bold.otf
  • CourierStd-Oblique.otf
  • CourierStd-BoldOblique.otf
  • MinionPro-Regular.otf
  • MinionPro-Bold.otf
  • MinionPro-It.otf
  • MinionPro-BoldIt.otf
  • MyriadPro-Regular.otf
  • MyriadPro-Bold.otf
  • MyriadPro-It.otf
  • MyriadPro-BoldIt.otf
  • SY______.PFB
  • AdobePiStd.otf
  • Arial-BoldMT.otf
  • ArialMT.ttf
  • Arial-ItalicMT.otf

Once you have the fonts, you can pass enable the standard-fonts for the pdf crate.

Workspace

This repository uses a Cargo Workspace and default members. This means by default only the pdf library is build. To build additional parts, pass --package=read to build the subcrate you are interested in (here the read example).

Examples

Currently we only have two very minimal examples read and text. However the library has grown a lot since they have been written.

Inspect

There is a tool for visualizing a PDF file as an interactive hierarchy of primitives at inspect-prim. Just clone and cargo run.

Viewer

run it: cargo run -p view --release --bin pdf_view YOUR_FILE.pdf Right now you can change pages with left and right arrow keys and zoom with '+' and '-'. Works for some files.