PDFDocument
classin packageklyn.io.pdf
public class PDFDocument implements AutoClosable
PDFDocument
All Implemented Interfaces: AutoClosable

Reads a PDF using Klyn's own parser, without an external PDF engine. Objects and page contents are decoded on demand. No scripts, actions or external resources embedded in a PDF are executed or fetched.

Supports classic cross-reference tables, cross-reference/object streams, incremental revisions, inherited page resources and Unicode font maps. Encrypted files and unsupported text encodings/filters raise PDFException. This reader extracts existing text; it does not rasterize pages or perform OCR. This initial API is read-only: writing or editing PDFs is not implemented. Supported stream filters are Flate, ASCIIHex, ASCII85 and RunLength, including TIFF/PNG predictors. Text extraction supports horizontal fonts with ToUnicode, StandardEncoding or WinAnsiEncoding, and standard Symbol/Dingbats encodings. Inline images, ActualText replacement spans, vertical fonts, external CMaps, and arbitrary Type3 font matrices are not supported and raise PDFException. Instances are not thread-safe; use one document per concurrent reader.

Example
import klyn.io.pdf
try document = PDFDocument("report.pdf"):
    for page in document.pages:
        print(page.getText())
Properties
Modifier and Type Member Description
public readonly property closed
closed as Boolean
Whether close() has released the document's source and object caches.
public readonly property pages
pages as IList<PDFPage>
Immutable, zero-based page sequence in the PDF page-tree order.
Constructors
Modifier and Type Member Description
public PDFDocument
PDFDocument(filename as String, maximumStreamSize as Int = 67108864)
Opens a PDF.
public PDFDocument
PDFDocument(path as Path, maximumStreamSize as Int = 67108864)
Opens a PDF from a Path, with the same limits as the String overload.
Methods
Modifier and Type Member Description
public close
close() as Void
Releases retained source data and caches.
Inherited Methods
methodInherited Methods from AutoClosable: close