Skip to content
Docs: API referenceMenu

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#

MemberDescription
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, PagesThe number of pages and the pages (PdfPage).
Info, XmpMetadata, VersionDocument information (title, author, subject, keywords, creator, producer, dates), the XMP packet and the PDF version.
IsEncrypted, PermissionsEncryption and the permissions it grants.
WasRepairedtrue when damaged or missing cross-reference data was rebuilt by scanning the file.
ExtractText(PdfTextOptions?)Text of all pages, separated by \f.
OutlinesThe bookmark tree (PdfOutlineItem: Title, PageNumber, Uri, Destination, Children, IsOpen).
FormFieldsThe 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#

MemberDescription
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, HeightPage 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#

OptionDefaultDescription
LayoutContentOrderContentOrder, the fastest, or ReadingOrder for multi-column pages
MaxDegreeOfParallelism1Pages extracted at once by PdfDocument.ExtractText; 0 uses all processors
IncludeAnnotationstrueInclude annotation appearances such as filled-in form fields
WordGapRatio0.15Gap, as a fraction of the font size, that starts a new word
LineGapRatio0.5Gap, as a fraction of the font size, that starts a new line
RemoveDuplicateGlyphstrueRemove glyphs drawn twice for fake bold

PdfReadOptions#

OptionDefaultDescription
PasswordemptyUser or owner password of an encrypted document
MaxDecodedStreamBytes256 MiBLargest decoded size of one stream
MaxObjects16 millionLargest number of objects
MaxFormDepth32Deepest nesting of Form XObjects

Exceptions#

ExceptionThrown when
PdfFormatExceptionThe input is not a PDF, is damaged beyond repair, or a stream exceeds MaxDecodedStreamBytes
PdfEncryptedExceptionA 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.