C# / .NET API Reference
The PdfOxide NuGet package wraps the Rust core via LibraryImport-generated P/Invoke (all 881 declarations). NativeAOT-publish-ready and trim-safe. Target frameworks: net8.0, net10.0.
dotnet add package PdfOxide
using PdfOxide.Core;
For other languages see Python, Node.js, Golang, or Rust.
Namespaces
using PdfOxide.Core; // PdfDocument, Pdf, DocumentEditor, DocumentBuilder, ...
using PdfOxide.Geometry; // Color, Point, Rect
using PdfOxide.Exceptions; // PdfException and typed subclasses
All native-backed types implement IDisposable — use using blocks or using declarations. Coordinates are in PDF points from the lower-left origin unless noted; colour channels passed as floats are 0.0–1.0.
PdfDocument
Read-only / extraction handle. PdfDocument is enumerable and indexable, yielding lazy Page handles.
Open
static PdfDocument Open(string path)
static PdfDocument Open(Stream stream)
static PdfDocument Open(byte[] data)
static PdfDocument Open(ReadOnlySpan<byte> data)
static PdfDocument OpenWithPassword(string path, string password)
static PdfDocument OpenFromDocxBytes(byte[] data)
static PdfDocument OpenFromPptxBytes(byte[] data)
static PdfDocument OpenFromXlsxBytes(byte[] data)
Open(...)— open from a path, stream, byte array, or span.OpenWithPassword(path, password)— open an encrypted PDF in one step.OpenFromDocxBytes/OpenFromPptxBytes/OpenFromXlsxBytes— convert Office bytes and open the result as a PDF (requires theofficefeature).
Properties
(byte Major, byte Minor) Version { get; } // PDF version, e.g. (1, 7)
int PageCount { get; } // number of pages
bool HasStructureTree { get; } // Tagged PDF with a structure tree
bool IsEncrypted { get; } // document is encrypted
bool HasXfa { get; } // contains XFA forms
int SignatureCount { get; } // number of digital signatures
IReadOnlyList<Signature> Signatures { get; } // signature handles
IReadOnlyList<Page> Pages { get; } // lazy per-page handles
Page this[int pageIndex] { get; } // page at index
Authentication
bool Authenticate(string password)
Authenticate an encrypted document after opening with a user or owner password. Returns true on success.
Text extraction
string ExtractText(int pageIndex)
string ExtractAllText()
Task<string> ExtractTextAsync(int pageIndex, CancellationToken cancellationToken = default)
string ExtractTextInRect(int pageIndex, float x, float y, float width, float height)
(string Text, float X, float Y, float W, float H)[] ExtractWords(int pageIndex)
(string Text, float X, float Y, float W, float H)[] ExtractWordsInRect(int pageIndex, float x, float y, float width, float height)
(string Text, float X, float Y, float W, float H)[] ExtractTextLines(int pageIndex)
(char Char, float X, float Y, float W, float H)[] ExtractChars(int pageIndex)
(float X, float Y, float W, float H, float StrokeWidth)[] ExtractPaths(int pageIndex)
Table[] ExtractTables(int pageIndex)
ExtractText/ExtractAllText— plain text from one page or the whole document.ExtractTextInRect— text inside a rectangular region.ExtractWords/ExtractWordsInRect— words with bounding boxes (optionally region-clipped).ExtractTextLines— lines with bounding boxes.ExtractChars— per-glyph positions.ExtractPaths— vector path segments with stroke widths.ExtractTables— detected tables (seeTable).
Classification & auto-extraction
string ExtractStructured(int page)
string ClassifyPage(int pageIndex)
string ClassifyDocument()
string ExtractTextAuto(int pageIndex)
string ExtractPageAuto(int pageIndex, string? optionsJson = null)
ExtractStructured— structured JSON of the page’s content.ClassifyPage/ClassifyDocument— classify a page or the whole document (e.g. scanned vs. digital).ExtractTextAuto— auto-route a page to the best text path (digital or OCR).ExtractPageAuto— auto-extraction with an optional JSON options blob.
Conversion
string ToMarkdown(int pageIndex)
string ToMarkdownAll()
string ToHtml(int pageIndex)
string ToHtmlAll()
string ToPlainText(int pageIndex)
string ToPlainTextAll()
byte[] ToDocxBytes()
byte[] ToPptxBytes()
byte[] ToXlsxBytes()
ToMarkdown/ToHtml/ToPlainText(+*All) — convert a page or the whole document.ToDocxBytes/ToPptxBytes/ToXlsxBytes— export to Office formats (requires theofficefeature).
Content cleanup
int RemoveHeaders(float threshold = 0.8f)
int RemoveFooters(float threshold = 0.8f)
int RemoveArtifacts(float threshold = 0.8f)
Detect and strip recurring running headers, footers, or page artifacts. Returns the number of elements removed. threshold is the cross-page recurrence ratio.
Search
(int Page, string Text, float X, float Y, float W, float H)[] SearchAll(string text, bool caseSensitive = false)
(int Page, string Text, float X, float Y, float W, float H)[] SearchPage(int pageIndex, string text, bool caseSensitive = false)
Search across the document or a single page; returns matches with page index and bounding box.
Structure & metadata
string GetPageLabels()
string GetXmpMetadata()
string GetOutline()
string PlanSplitByBookmarks(int level, string? namePattern = null)
string[] GetFonts(int pageIndex)
GetPageLabels— page-label ranges (JSON).GetXmpMetadata— XMP metadata (JSON / XML packet).GetOutline— bookmark tree / table of contents (JSON).PlanSplitByBookmarks— compute a split plan at a bookmark level.GetFonts— font names used on a page.
Images
ExtractedImage[] ExtractImages(int pageIndex)
Extract embedded images with metadata and raw bytes (see ExtractedImage).
Forms
FormField[] GetFormFields()
Enumerate AcroForm fields (see FormField).
Rendering
byte[] RenderPage(int pageIndex, int format = 0)
byte[] RenderPage(int pageIndex, RenderOptions options)
byte[] RenderPageZoom(int pageIndex, float zoom, int format = 0)
byte[] RenderPageFit(int pageIndex, int fitWidth, int fitHeight, int format = 0)
byte[] RenderThumbnail(int pageIndex, int format = 0)
RgbaPixmap RenderToRgba(int pageIndex, int dpi = 150)
void SaveRenderedImage(int pageIndex, string filePath, int format = 0)
RenderPage— render at default DPI (format:0= PNG,1= JPEG) or with fullRenderOptions.RenderPageZoom— render at a zoom factor.RenderPageFit— render scaled to fit a pixel box.RenderThumbnail— render a small thumbnail.RenderToRgba— render to a raw RGBA pixmap (seeRgbaPixmap).SaveRenderedImage— render and write directly to a file.
Signatures
unsafe DocumentSecurityStore? GetDss()
bool HasDocumentTimestamp()
GetDss— read the Document Security Store (DSS), if present.HasDocumentTimestamp— whether a document-level timestamp is present.
See Signature for per-signature verification.
Static configuration
static void SetLogLevel(int level)
static int GetLogLevel()
static string PrefetchModels(params string[] languages)
static string ModelManifest()
static bool PrefetchAvailable()
static string GetActiveCryptoProvider()
static bool IsFipsCryptoAvailable()
static void UseFipsCryptoProvider()
static void SetCryptoPolicy(string spec)
static string CryptoPolicy()
static string[] CryptoInventory()
static string CryptoCbom()
SetLogLevel/GetLogLevel— control native log verbosity.PrefetchModels/ModelManifest/PrefetchAvailable— manage OCR model downloads.GetActiveCryptoProvider/IsFipsCryptoAvailable/UseFipsCryptoProvider— crypto-provider selection (FIPS).SetCryptoPolicy/CryptoPolicy— get/set the active crypto policy.CryptoInventory/CryptoCbom— enumerate crypto usage / emit a CBOM.
Dispose
void Dispose()
Page
Lazy per-page handle from doc[i] or iteration. All members dispatch to the parent document.
int Index { get; }
string ExtractText();
Task<string> ExtractTextAsync(CancellationToken ct = default);
string ToMarkdown();
Task<string> ToMarkdownAsync(CancellationToken ct = default);
string ToHtml();
Task<string> ToHtmlAsync(CancellationToken ct = default);
string ToPlainText();
Task<string> ToPlainTextAsync(CancellationToken ct = default);
(string Text, float X, float Y, float W, float H)[] ExtractWords();
(string Text, float X, float Y, float W, float H)[] ExtractLines();
(char Char, float X, float Y, float W, float H)[] ExtractChars();
(float X, float Y, float W, float H, float StrokeWidth)[] ExtractPaths();
Table[] ExtractTables();
ExtractedImage[] ExtractImages();
string[] GetFonts();
(int Page, string Text, float X, float Y, float W, float H)[] Search(string text, bool caseSensitive = false);
byte[] Render(int format = 0);
byte[] RenderThumbnail(int format = 0);
Pdf — creation
Create a PDF from a source format, then save.
static Pdf FromMarkdown(string markdown)
static Pdf FromHtml(string html)
static Pdf FromHtmlCss(string html, string css, byte[] fontBytes)
static unsafe Pdf FromHtmlCssWithFonts(string html, string css, (string Name, byte[] Bytes)[] fonts)
static Pdf FromText(string text)
static Pdf FromImage(string path)
static Pdf FromImageBytes(byte[] data)
int PageCount { get; }
void Save(string path)
byte[] SaveToBytes()
void SaveToStream(Stream stream)
Task SaveAsync(string path, CancellationToken cancellationToken = default)
Task SaveToStreamAsync(Stream stream, CancellationToken cancellationToken = default)
void Dispose()
FromMarkdown/FromHtml/FromText— create from text formats.FromHtmlCss/FromHtmlCssWithFonts— HTML + CSS pipeline with embedded fonts.FromImage/FromImageBytes— single-page PDF from an image.Save/SaveToBytes/SaveToStream(+ async) — persist the result.
DocumentEditor
Mutable editor for existing PDFs: metadata, pages, forms, redaction, encryption.
Open & save
static DocumentEditor Open(string path)
static DocumentEditor OpenFromBytes(byte[] data)
void Save(string path)
Task SaveAsync(string path, CancellationToken cancellationToken = default)
byte[] SaveToBytes()
byte[] SaveToBytesWithOptions(bool compress, bool garbageCollect, bool linearize)
void SaveEncrypted(string path, string userPassword, string ownerPassword)
byte[] SaveEncryptedToBytes(string userPassword, string ownerPassword)
unsafe byte[] ExtractPages(int[] pageIndices)
void Dispose()
Properties
bool IsModified { get; }
string SourcePath { get; }
(byte Major, byte Minor) Version { get; }
int PageCount { get; }
string? Title { get; set; }
string? Author { get; set; }
string? Subject { get; set; }
string? Keywords { get; set; }
string? Producer { get; set; }
string? CreationDate { get; set; }
string[] FlattenWarnings { get; }
Page operations
void MergeFrom(string sourcePath)
int MergeFromBytes(byte[] data)
void DeletePage(int pageIndex)
void MovePage(int fromIndex, int toIndex)
int GetPageRotation(int pageIndex)
void SetPageRotation(int pageIndex, int degrees)
void RotateAllPages(int degrees)
void RotatePageBy(int pageIndex, int degrees)
void CropMargins(float left, float right, float top, float bottom)
(double X, double Y, double Width, double Height) GetPageMediaBox(int pageIndex)
void SetPageMediaBox(int pageIndex, double x, double y, double width, double height)
(double X, double Y, double Width, double Height) GetPageCropBox(int pageIndex)
void SetPageCropBox(int pageIndex, double x, double y, double width, double height)
MergeFrom/MergeFromBytes— append pages from another PDF (MergeFromBytesreturns merged page count).DeletePage/MovePage— remove or reorder pages.GetPageRotation/SetPageRotation/RotateAllPages/RotatePageBy— rotation control (absolute vs. relative).CropMargins— crop all page margins.Get/SetPageMediaBoxandGet/SetPageCropBox— page geometry boxes.
Erase / whiteout
void EraseRegion(int pageIndex, float x, float y, float width, float height)
void EraseRegions(int pageIndex, double[][] rects)
void ClearEraseRegions(int pageIndex)
Annotations & forms
void SetFormFieldValue(string name, string value)
void FlattenForms()
void FlattenFormsOnPage(int pageIndex)
void FlattenAnnotations(int pageIndex)
void FlattenAllAnnotations()
bool IsPageMarkedForFlatten(int pageIndex)
void UnmarkPageForFlatten(int pageIndex)
Redaction
void AddRedaction(int pageIndex, double x1, double y1, double x2, double y2, byte r, byte g, byte b)
int RedactionCount(int pageIndex)
void ApplyPageRedactions(int pageIndex)
void ApplyAllRedactions()
int ApplyRedactions(bool scrubMetadata = true, bool scrubText = true)
bool IsPageMarkedForRedaction(int pageIndex)
void UnmarkPageForRedaction(int pageIndex)
int SanitizeDocument()
AddRedaction— queue a redaction rectangle with a fill colour.ApplyPageRedactions/ApplyAllRedactions/ApplyRedactions— burn in pending redactions (ApplyRedactionsoptionally scrubs metadata/hidden text).SanitizeDocument— remove hidden/unreferenced data; returns the count scrubbed.
Other
void EmbedFile(string name, byte[] data)
void ConvertToPdfA(PdfALevel level = PdfALevel.A2b)
EmbedFile— attach a file to the PDF.ConvertToPdfA— convert to a PDF/A conformance level.
The exact
AddRedaction/ApplyRedactionssignatures use snake-case native arguments under the hood; the C# surface shown here is the public binding.
DocumentBuilder
Fluent builder for new documents. DocumentBuilder.Create() → metadata → page(s) → Build() / Save().
static DocumentBuilder Create()
DocumentBuilder Title(string title)
DocumentBuilder Author(string author)
DocumentBuilder Subject(string subject)
DocumentBuilder Keywords(string keywords)
DocumentBuilder Creator(string creator)
DocumentBuilder OnOpen(string script) // document-open JavaScript
DocumentBuilder TaggedPdfUa1() // emit a Tagged PDF/UA-1
DocumentBuilder Language(string lang)
DocumentBuilder RoleMap(string custom, string standard)
DocumentBuilder RegisterEmbeddedFont(string name, EmbeddedFont font)
PageBuilder A4Page()
PageBuilder LetterPage()
PageBuilder Page(float width, float height)
byte[] Build()
void Save(string path)
void SaveEncrypted(string path, string userPassword, string ownerPassword)
byte[] ToBytesEncrypted(string userPassword, string ownerPassword)
void Dispose()
PageBuilder
Per-page fluent surface returned by A4Page() / LetterPage() / Page(w, h). Each method returns the builder for chaining; Done() commits the page back to the parent.
Text & layout
PageBuilder Font(string name, float size)
PageBuilder At(float x, float y)
PageBuilder Text(string text)
PageBuilder Heading(byte level, string text)
PageBuilder Paragraph(string text)
PageBuilder Space(float points)
PageBuilder HorizontalRule()
PageBuilder Newline()
PageBuilder Columns(uint columnCount, float gapPt, string text)
PageBuilder Footnote(string refMark, string noteText)
PageBuilder TextInRect(float x, float y, float w, float h, string text, Alignment align = Alignment.Left)
PageBuilder NewPageSameSize()
float Measure(string text)
float RemainingSpace()
Inline runs
PageBuilder Inline(string text)
PageBuilder InlineBold(string text)
PageBuilder InlineItalic(string text)
PageBuilder InlineColor(float r, float g, float b, string text)
Links & JavaScript
PageBuilder LinkUrl(string url)
PageBuilder LinkPage(int pageIndex)
PageBuilder LinkNamed(string destination)
PageBuilder LinkJavascript(string script)
PageBuilder OnOpen(string script)
PageBuilder OnClose(string script)
PageBuilder FieldKeystroke(string script)
PageBuilder FieldFormat(string script)
PageBuilder FieldValidate(string script)
PageBuilder FieldCalculate(string script)
Annotations
PageBuilder Highlight(float r, float g, float b)
PageBuilder Underline(float r, float g, float b)
PageBuilder Strikeout(float r, float g, float b)
PageBuilder Squiggly(float r, float g, float b)
PageBuilder StickyNote(string text)
PageBuilder StickyNoteAt(float x, float y, string text)
PageBuilder Watermark(string text)
PageBuilder WatermarkConfidential()
PageBuilder WatermarkDraft()
PageBuilder Stamp(string typeName)
PageBuilder FreeText(float x, float y, float w, float h, string text)
Form widgets
PageBuilder TextField(string name, float x, float y, float w, float h, string? defaultValue = null)
PageBuilder Checkbox(string name, float x, float y, float w, float h, bool @checked = false)
unsafe PageBuilder ComboBox(string name, float x, float y, float w, float h, string[] options, string? selected = null)
unsafe PageBuilder RadioGroup(string name, (string Value, float X, float Y, float W, float H)[] buttons, string? selected = null)
PageBuilder PushButton(string name, float x, float y, float w, float h, string caption)
PageBuilder SignatureField(string name, float x, float y, float w, float h)
Graphics
PageBuilder Rect(float x, float y, float w, float h)
PageBuilder FilledRect(float x, float y, float w, float h, float r, float g, float b)
PageBuilder Line(float x1, float y1, float x2, float y2)
PageBuilder StrokeRect(float x, float y, float w, float h, float width = 1f, float r = 0f, float g = 0f, float b = 0f)
PageBuilder StrokeLine(float x1, float y1, float x2, float y2, float width = 1f, float r = 0f, float g = 0f, float b = 0f)
unsafe PageBuilder StrokeRectDashed(float x, float y, float w, float h, float[] dash, float phase = 0f, float width = 1f, float r = 0f, float g = 0f, float b = 0f)
unsafe PageBuilder StrokeLineDashed(float x1, float y1, float x2, float y2, float[] dash, float phase = 0f, float width = 1f, float r = 0f, float g = 0f, float b = 0f)
Images & barcodes
unsafe PageBuilder Image(byte[] imageBytes, float x, float y, float w, float h)
unsafe PageBuilder ImageWithAlt(byte[] imageBytes, float x, float y, float w, float h, string altText)
unsafe PageBuilder ImageArtifact(byte[] imageBytes, float x, float y, float w, float h)
PageBuilder Barcode1d(int barcodeType, string data, float x, float y, float w, float h)
PageBuilder BarcodeQr(string data, float x, float y, float size)
Tables
unsafe PageBuilder Table(TableSpec spec)
StreamingTable StreamingTable(IReadOnlyList<Column> columns, bool repeatHeader = true,
TableMode? mode = null, int maxRowspan = 1, int batchSize = 256)
DocumentBuilder Done()
void Dispose()
Table— render a fully-materialised table from aTableSpec.StreamingTable— open a streaming table for large/row-by-row data (seeStreamingTable).Done— commit the page and return the parentDocumentBuilder.
EmbeddedFont
static EmbeddedFont FromFile(string path)
static EmbeddedFont FromBytes(byte[] data, string? name = null)
void Dispose()
Load a TTF/OTF font for embedding via DocumentBuilder.RegisterEmbeddedFont.
StreamingTable
Row-by-row table builder for large datasets, returned by PageBuilder.StreamingTable(...).
unsafe StreamingTable AddRow(params string[] cells)
unsafe StreamingTable AddRowSpan(params (string? Text, int Rowspan)[] cells)
void Flush()
PageBuilder Build()
void Dispose()
AddRow— append a row of cells.AddRowSpan— append a row with per-cell rowspans (requiresmaxRowspan >= 2).Flush— flush buffered rows to the native layer.Build— finalise and return the parentPageBuilder.
OcrEngine
OCR over scanned PDFs (requires the ocr feature). Models are loaded from detection / recognition / dictionary paths.
static OcrEngine Load(string detectionModelPath, string recognitionModelPath, string dictionaryPath)
static bool PageNeedsOcr(PdfDocument document, int pageIndex)
string ExtractText(PdfDocument document, int pageIndex)
void Dispose()
Load— load an engine from model files.PageNeedsOcr— heuristic check whether a page lacks a digital text layer.ExtractText— run OCR on a page.
See also PdfDocument.PrefetchModels, ModelManifest, and PrefetchAvailable.
Digital signatures
Signature
Per-signature handle from PdfDocument.Signatures.
string? SignerName { get; }
string? Reason { get; }
string? Location { get; }
Certificate GetCertificate()
bool Verify()
bool VerifyDetached(ReadOnlySpan<byte> pdfData)
void Dispose()
Verify— validate the signature’s cryptographic integrity.VerifyDetached— additionally validate themessageDigestagainst the supplied PDF bytes.GetCertificate— the signer’s certificate.
Certificate
static Certificate LoadFromPem(string certPem, string keyPem)
static Certificate Load(byte[] data, string? password = null)
unsafe byte[] SignPdfBytes(byte[] pdfData, string? reason = null, string? location = null)
unsafe byte[] SignPdfBytesPades(byte[] pdfData, PadesSignOptions options)
void Dispose()
LoadFromPem/Load— load a signing certificate (PEM pair, or PKCS#12 bytes with optional password).SignPdfBytes— sign with a basic CMS signature.SignPdfBytesPades— sign with a PAdES profile (seePadesSignOptions).
Timestamp
static Timestamp Parse(byte[] data)
string Serial { get; }
string PolicyOid { get; }
string TsaName { get; }
bool Verify()
void Dispose()
TsaClient
static TsaClient Create(TsaClientOptions options)
Timestamp RequestTimestamp(byte[] data)
Timestamp RequestTimestampHash(byte[] hash, TimestampHashAlgorithm hashAlgorithm)
void Dispose()
TsaClientOptions (init-only): Url (required), Username, Password, TimeoutSeconds (= 30), HashAlgorithm (= Sha256), UseNonce (= true), CertReq (= true). Behind the tsa-client feature.
Barcode
static Barcode GenerateQrCode(string data, int errorCorrection = 1, int sizePx = 300)
static Barcode Generate(string data, BarcodeFormat format = BarcodeFormat.Code128, int sizePx = 300)
byte[] ToPng(int sizePx = 300)
string ToSvg()
void Dispose()
BarcodeFormat: Code128, Code39, Ean13, Ean8, UpcA, Itf.
PdfValidator
Static compliance checks. Each returns a PdfValidationResult.
static PdfValidationResult ValidatePdfA(PdfDocument document, PdfALevel level = PdfALevel.A2b)
static PdfValidationResult ValidatePdfX(PdfDocument document, PdfXLevel level = PdfXLevel.X4)
static PdfValidationResult ValidatePdfUA(PdfDocument document, PdfUaLevel level = PdfUaLevel.Ua1)
Data types
RgbaPixmap
public sealed record RgbaPixmap(ReadOnlyMemory<byte> Data, int Width, int Height);
Table
public sealed class Table
{
public int RowCount { get; }
public int ColCount { get; }
public bool HasHeader { get; }
}
ExtractedImage
public sealed class ExtractedImage
{
public int Width { get; }
public int Height { get; }
public string Format { get; }
public string Colorspace { get; }
public int BitsPerComponent { get; }
public byte[] Data { get; }
}
FormField
public sealed class FormField
{
public string Name { get; }
public string FieldType { get; }
public string Value { get; }
}
TableSpec
public sealed class TableSpec
{
public List<Column> Columns { get; set; }
public IList<IList<string>> Rows { get; set; }
public bool HasHeader { get; set; }
}
public sealed class Column
{
public string Header { get; set; }
public float Width { get; set; }
public Alignment Align { get; set; }
public Column(string header, float width, Alignment align = Alignment.Left);
}
public abstract class TableMode
{
public sealed class Fixed : TableMode { }
public sealed class Sample : TableMode
{
public int SampleRows { get; init; } // = 20
public float MinColWidthPt { get; init; } // = 0
public float MaxColWidthPt { get; init; } // = 9999
}
}
public enum Alignment { Left = 0, Center = 1, Right = 2 }
RenderOptions
public sealed class RenderOptions
{
public int Dpi { get; set; } // = 150
public RenderImageFormat Format { get; set; } // = Png
public bool TransparentBackground { get; set; }
public bool RenderAnnotations { get; set; } // = true
public int JpegQuality { get; set; } // = 85
}
public enum RenderImageFormat { Png = 0, Jpeg = 1 }
PAdES / DSS types
public enum PadesLevel { BB = 0, BT = 1, BLt = 2, BLta = 3 }
public sealed class PadesSignOptions
{
public PadesLevel Level { get; set; } // = BB
public string? TsaUrl { get; set; }
public string? Reason { get; set; }
public string? Location { get; set; }
public RevocationMaterial? Revocation { get; set; }
}
public sealed class RevocationMaterial
{
public IList<byte[]> Certificates { get; }
public IList<byte[]> Crls { get; }
public IList<byte[]> OcspResponses { get; }
}
public sealed class DocumentSecurityStore
{
public IReadOnlyList<byte[]> Certificates { get; }
public IReadOnlyList<byte[]> Crls { get; }
public IReadOnlyList<byte[]> OcspResponses { get; }
public int VriCount { get; }
}
public enum TimestampHashAlgorithm { Unknown = 0, Sha1 = 1, Sha256 = 2, Sha384 = 3, Sha512 = 4 }
Validation types
public sealed class PdfValidationResult
{
public bool IsCompliant { get; }
public IReadOnlyList<string> Errors { get; }
public IReadOnlyList<string> Warnings { get; }
}
public enum PdfALevel { A1b = 0, A1a = 1, A2b = 2, A2a = 3, A2u = 4, A3b = 5, A3a = 6, A3u = 7 }
public enum PdfXLevel { X1a = 0, X3 = 1, X4 = 2 }
public enum PdfUaLevel { Ua1 = 1, Ua2 = 2 }
Geometry (PdfOxide.Geometry)
public struct Color : IEquatable<Color>
{
public Color(byte red, byte green, byte blue);
public Color(byte red, byte green, byte blue, byte alpha);
public byte Red { get; }
public byte Green { get; }
public byte Blue { get; }
public byte Alpha { get; }
public static Color FromArgb(uint argb);
public uint ToArgb();
public string ToHex();
public static Color Black { get; }
public static Color White { get; }
public static Color Yellow { get; }
public static Color Cyan { get; }
public static Color Magenta { get; }
}
public struct Point : IEquatable<Point>
{
public Point(float x, float y);
public float X { get; }
public float Y { get; }
public float Magnitude { get; }
public float Distance(Point other);
// operators: + - * / == !=
}
public struct Rect : IEquatable<Rect>
{
public Rect(float x, float y, float width, float height);
public float X { get; }
public float Y { get; }
public float Width { get; }
public float Height { get; }
public bool Contains(Point point);
public bool Intersects(Rect other);
}
Exceptions
All native failures raise PdfException (in PdfOxide.Exceptions):
public class PdfException : Exception
{
public string Code { get; }
public static string GetErrorMessage(int errorCode);
public PdfException WithContext(string operation, params (string key, object? value)[] context);
}
Typed subclasses cover specific categories — for example: ParseException, InvalidStructure, CorruptedData, UnsupportedVersion, EncryptionException, InvalidPassword, DecryptionFailed, UnsupportedAlgorithm, DocumentClosed, OperationNotAllowed, UnsupportedFeatureException, FeatureNotImplemented, FormatNotSupported, ValidationException, InvalidParameter, MissingRequired, RenderingException, RenderFailed, UnsupportedRenderFormat, SearchException, InvalidPattern, SignatureException, RedactionException, AccessibilityException, OptimizationException, ComplianceException, ComplianceFailed, OcrException, RecognitionFailed, LanguageNotSupported, ImageProcessingFailed, InternalError, and XfaException.
try
{
using var doc = PdfDocument.Open("file.pdf");
var text = doc.ExtractText(0);
}
catch (InvalidPassword)
{
// wrong / missing password
}
catch (UnsupportedFeatureException)
{
// feature not compiled into this build (e.g. ocr, office)
}
catch (PdfException e)
{
Console.Error.WriteLine($"{e.Code}: {e.Message}");
}
Standard .NET exceptions are still raised for I/O (FileNotFoundException, etc.) and argument validation (ArgumentOutOfRangeException, ArgumentNullException).
Thread safety
PdfDocumentread-only methods are thread-safe — share a single document across threads.DocumentEditorand the builders are not thread-safe for writes. Serialize writes to one thread or guard with a lock.
See the concurrency guide.
Async pattern
I/O-bound methods expose *Async variants accepting CancellationToken (ExtractTextAsync, SaveAsync, SaveToStreamAsync, and the Page.*Async family). See the async guide.
NativeAOT
Publish with -p:PublishAot=true. No extra configuration — all P/Invoke is source-generated, no reflection, no dynamic code.
Complete example
using PdfOxide.Core;
// --- Creation ---
using (var builder = DocumentBuilder.Create()
.Title("Report").Author("PDF Oxide"))
{
builder.LetterPage()
.Heading(1, "Quarterly Report")
.Paragraph("Generated by PDF Oxide.")
.LinkUrl("https://oxide.fyi")
.Done();
builder.Save("report.pdf");
}
// --- Extraction ---
using var doc = PdfDocument.Open("report.pdf");
Console.WriteLine($"Pages: {doc.PageCount}");
foreach (var page in doc)
Console.WriteLine($"Page {page.Index}: {page.ExtractText().Length} chars");
// Search with LINQ
var hits = doc.SearchAll("Report", caseSensitive: false)
.GroupBy(r => r.Page);
// --- Editing ---
using (var editor = DocumentEditor.Open("report.pdf"))
{
editor.Title = "Updated Title";
editor.RotateAllPages(90);
editor.SetFormFieldValue("name", "Jane Doe");
editor.Save("report-updated.pdf");
}
// --- Rendering ---
byte[] png = doc.RenderPage(0, new RenderOptions { Dpi = 200, Format = RenderImageFormat.Png });
File.WriteAllBytes("page0.png", png);
Other Language Bindings
PDF Oxide ships native bindings for every major ecosystem: Rust, Python, Node.js, WASM, Golang, Java, PHP, Ruby, C++, Swift, Kotlin, Dart, R, Julia, Zig, Scala, Clojure, Objective-C, and Elixir.
Next Steps
- Types & Enums — all shared types and enums
- Page API Reference — consistent per-page iteration across bindings
- Getting Started with C# — tutorial