pdf-toolbox-core-0.0.4.1: A collection of tools for processing PDF files.

Safe HaskellNone
LanguageHaskell98

Pdf.Toolbox.Core.Parsers.XRef

Description

Parsers for XRef

Synopsis

Documentation

startXRef :: Parser Int64 Source

Offset of the very last xref table

Before calling it, make sure your are currently somewhere near the end of pdf file. Otherwice it can eat all the memory. E.g. examine only the last 1KB

>>> parseOnly startXRef "anything...startxref\n222\n%%EOF...blah\nstartxref\n123\n%%EOF"
Right 123

tableXRef :: Parser () Source

When current input position points to xref stream (or doesn't point to xref at all), the parser will fail. When it points to xref table, the parser will succeed and input position will point to the first xref subsection

>>> parseOnly tableXRef "xref\n"
Right ()
>>> parseOnly tableXRef "not xref"
Left "Failed reading: takeWith"

parseSubsectionHeader :: Parser (Int, Int) Source

Parse subsection header, return (the first object index, number of object)

Input position will point to the first object

parseTrailerAfterTable :: Parser Dict Source

Parse trailer located after XRef table

Input position should point to the "trailer" keyword

parseTableEntry :: Parser (Int64, Int, Bool) Source

Parse XRef table entry. Returns offset, generation and whether the object is free.