Skip to content

PDF parser and renderer. Includes a PostScript interpreter, a Type 1 font renderer, a TTF renderer, and a PNG decoder

License

Notifications You must be signed in to change notification settings

connorskees/pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF parser and renderer

An attempt at writing a PDF renderer from as close to scratch as possible.

This project includes from-scratch parsers/interpreters/renderers/implementations of PostScript, ICC profiles, PNG compression, Type 1 fonts (.pfb files), TrueType fonts (.ttf files), CFF (compact fonts), 2d path manipulation and rasterization, among others.

This library is intended to crash on malformed input and makes heavy use of assertions to ensure that parsing is never silently incorrect.

This library is not suited for the regular user, and has limited utility outside of the niche cases that I personally use it for.

As a parser, this projects is the most comprehensive pure-rust implementation I am aware of, though as a renderer it is less complete.

It should be noted that this library will intentionally deviate from the spec when there is the potential for network/disk access or RCE through PDF files. See https://web-in-security.blogspot.com/2021/01/insecure-features-in-pdfs.html for a good reference of just some of such features.

Reading

Specifications and formats

https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf
http://www.libpng.org/pub/png/spec/1.2/png-1.2.pdf
https://www.adobe.com/content/dam/acom/en/devnet/postscript/pdfs/TN5603.Filters.pdf
https://www.adobe.com/content/dam/acom/en/devnet/actionscript/articles/psrefman.pdf
https://developer.apple.com/fonts/TrueType-Reference-Manual
https://hepunx.rl.ac.uk/~adye/psdocs/ref/REF.html
http://fileformats.archiveteam.org/wiki/PostScript_binary_object_format
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5176.CFF.pdf
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5177.Type2.pdf
https://www.color.org/icc1v42.pdf
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5049.StemSnap.pdf
https://www.pdfa.org/norm-refs/5620.PortableJobTicket.pdf
https://www.itu.int/rec/T-REC-T.6-198811-I/en

True Type Resources

https://www.truetype-typography.com/tthints.htm
https://learn.microsoft.com/en-us/typography/opentype/spec/ttch01
https://developer.apple.com/fonts/TrueType-Reference-Manual
https://xgridfit.sourceforge.net/round.html

Algorithms and Relevant Literature

http://members.chello.at/~easyfilter/Bresenham.pdf
https://en.wikipedia.org/wiki/Ascii85
https://pomax.github.io/bezierinfo
https://secure.math.ubc.ca/~cass/piscript/type1.pdf
https://ltr.wtf/explained/bidiintro.html
https://scholarsarchive.byu.edu/cgi/viewcontent.cgi?article=1000&context=facpub
https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html
http://www.cccg.ca/proceedings/2004/36.pdf

Other resources

https://speakerdeck.com/ange/lets-write-a-pdf-file
https://web.archive.org/web/20150110042057/http://home.comcast.net/~jk05/presentations/PDFTutorials.html/
http://formats.kaitai.io/ttf/ttf.svg/
https://www.tinaja.com/glib/interdic.pdf
https://personal.math.ubc.ca/~cass/piscript/type1.pdf

About

PDF parser and renderer. Includes a PostScript interpreter, a Type 1 font renderer, a TTF renderer, and a PNG decoder

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published