API reference
The Hypapdf .NET API: PdfDocument, PdfPage, text, layout, form, image and navigation types, PdfTextOptions, PdfReadOptions and the exceptions it throws.
v0.1.0Last updated View as Markdown
Every public type is in the Hypapdf namespace.
PdfDocument#
| Member | Description |
|---|---|
PdfDocument.OpenAsync(path | Stream, PdfReadOptions?, CancellationToken) | Opens a document; files and streams are read asynchronously. Only the cross-reference data is read; everything else is parsed on first use. |
PdfDocument.Open(byte[] | ReadOnlyMemory<byte> | Stream, PdfReadOptions?) | Opens data already in memory synchronously. A byte[] is used in place, not copied. |
PageCount, Pages | The number of pages and the pages (PdfPage). |
Info, XmpMetadata, Version | Document information (title, author, subject, keywords, creator, producer, dates), the XMP packet and the PDF version. |
IsEncrypted, Permissions | Encryption and the permissions it grants. |
WasRepaired | true when damaged or missing cross-reference data was rebuilt by scanning the file. |
ExtractText(PdfTextOptions?) | Text of all pages, separated by \f. |
Outlines | The bookmark tree (PdfOutlineItem: Title, PageNumber, Uri, Destination, Children, IsOpen). |
FormFields | The terminal fields of the interactive form (PdfFormField: FullName, Type, Value, Values, IsChecked, Options, Widgets, PageNumber, flags). |
Catalog, Trailer, GetObject(int), Resolve(PdfObject) | The object model. |
PdfPage#
| Member | Description |
|---|---|
ExtractText(PdfTextOptions?) | Text of the page. |
GetLetters() | Every glyph with its position, size and font (PdfLetter). Coordinates are in user space: points, origin bottom left. |
GetWords(PdfTextOptions?) | Words with bounding boxes, font, size and rotation, in content order (PdfWord). |
GetTextBlocks(PdfTextOptions?) | Blocks of lines of words in reading order (PdfTextBlock, PdfTextLine). |
GetImages(bool includeAnnotations = true) | The images drawn on the page (PdfImage: Width, Height, ColorSpace, Format, Bounds, GetEncodedData(), ToPng()). |
GetLinks() | The link annotations (PdfLink: Bounds, PageNumber, Uri, RemoteFile, Destination). |
MediaBox, CropBox, Rotation, Width, Height | Page geometry. |
Resources, Dictionary, GetContentData() | The page’s resources and dictionary, and its decoded content stream. |
Object model#
PdfDictionary, PdfArray, PdfStream, PdfName, PdfString (PDFDocEncoding, UTF-16BE, UTF-8), PdfInteger, PdfReal, PdfBoolean, PdfNull and PdfReference. PdfStream.GetData() returns the decoded bytes, GetRawData() the bytes as stored.
PdfTextOptions#
| Option | Default | Description |
|---|---|---|
Layout | ContentOrder | ContentOrder, the fastest, or ReadingOrder for multi-column pages |
MaxDegreeOfParallelism | 1 | Pages extracted at once by PdfDocument.ExtractText; 0 uses all processors |
IncludeAnnotations | true | Include annotation appearances such as filled-in form fields |
WordGapRatio | 0.15 | Gap, as a fraction of the font size, that starts a new word |
LineGapRatio | 0.5 | Gap, as a fraction of the font size, that starts a new line |
RemoveDuplicateGlyphs | true | Remove glyphs drawn twice for fake bold |
PdfReadOptions#
| Option | Default | Description |
|---|---|---|
Password | empty | User or owner password of an encrypted document |
MaxDecodedStreamBytes | 256 MiB | Largest decoded size of one stream |
MaxObjects | 16 million | Largest number of objects |
MaxFormDepth | 32 | Deepest nesting of Form XObjects |
Exceptions#
| Exception | Thrown when |
|---|---|
PdfFormatException | The input is not a PDF, is damaged beyond repair, or a stream exceeds MaxDecodedStreamBytes |
PdfEncryptedException | A password is needed or wrong, or the document uses a public-key security handler |
Malformed input is meant to surface only as these exceptions, never as a crash or a hang.