π Complete API Reference
Every public class, method, property, and enum in ObviousPDF.
π₯ Download Markdown
PdfDocument
namespace ObviousPDF β The main entry point for creating PDF files.
var doc = new PdfDocument();
doc.Info.Title = "My Document";
doc.Language = "en-US";
doc.Save("output.pdf");
Properties
| Property | Type | Default | Description |
Info | PdfDocumentInfo | (empty) | Document metadata (title, author, subject, etc.) |
Language | string? | null | BCP 47 language tag (e.g. "en-US"). Required for PDF/UA. |
DisplayDocTitle | bool | false | Show title in viewer title bar. Required for PDF/UA. |
PdfVersion | string? | null | Explicit PDF version (e.g. "2.0"). Auto-inferred when null. |
PdfAConformance | PdfAConformanceLevel | None | PDF/A archival conformance level. |
PdfUaConformance | PdfUaConformanceLevel | None | PDF/UA accessibility conformance level. |
UseCrossReferenceStreams | bool | false | Use compact xref streams (PDF 1.5+). |
UseObjectStreams | bool | false | Pack objects in compressed streams (PDF 1.5+). |
Encryption | PdfEncryption? | null | Encryption settings (AES-128 or AES-256). |
Linearize | bool | false | Enable fast web view (linearized PDF). |
IsTagged | bool | (read-only) | Whether tagged PDF is enabled. |
StructureTreeRoot | PdfStructureElement? | (read-only) | Root of the structure tree, or null. |
Methods
| Method | Returns | Description |
AddPage(double width = 612, double height = 792) | PdfPageBuilder | Adds a page with custom dimensions (points). |
AddPage((double, double) pageSize) | PdfPageBuilder | Adds a page using a PageSize constant. |
EnableTaggedPdf() | PdfStructureElement | Enables tagged PDF; returns root Document element. |
AddRoleMapping(string, StructureType) | void | Maps custom structure type to standard type. |
AddOutline(string title, int pageIndex) | PdfOutlineItem | Adds a top-level bookmark. |
AddPageLabels(int, PdfPageLabelStyle, string?, int) | PdfPageLabel | Adds a page label range. |
CreateFormXObject(double w, double h) | PdfFormXObject | Creates a reusable form XObject. |
CreateOptionalContentGroup(string, bool) | PdfOptionalContentGroup | Creates an OCG (layer). |
AddAssociatedFile(string, string, byte[], ...) | PdfAssociatedFile | Attaches a document-level file. |
CreateDocumentPartRoot() | PdfDocumentPart | Creates root for document part hierarchy. |
Save(string filePath) | void | Writes PDF to a file path. |
Save(Stream stream) | void | Writes PDF to any stream. |
Sign(string filePath, PdfDigitalSignature) | void | Saves and digitally signs the PDF. |
PdfPageBuilder
namespace ObviousPDF β Fluent API for adding content to a single PDF page.
Text Methods
| Method | Description |
AddText(string text, double x, double y, PdfTextOptions?) | Single line of text at (x, y). |
AddTextBlock(IEnumerable<string>, double x, double y, PdfTextOptions?) | Multi-line text with auto line advance. |
BeginTextBlock() / EndTextBlock() | Fine-grained text block control. |
SetFont(StandardFont, double) | Sets standard font inside a text block. |
SetFont(PdfEmbeddedFont, double) | Sets embedded font inside a text block. |
SetColor(PdfColor) | Sets text colour using any colour space. |
SetTextRenderingMode(PdfTextRenderingMode) | Sets rendering mode (fill, stroke, clip, invisible). |
MoveTextTo(double x, double y) | Moves text cursor inside a text block. |
ShowText(string text) | Renders text at current position inside a text block. |
Vector Graphics Methods
| Method | Description |
DrawLine(double x1, double y1, double x2, double y2, PdfDrawOptions?) | Draws a line between two points. |
DrawRectangle(double x, y, w, h, PdfDrawOptions?) | Rectangle outline. |
FillRectangle(double x, y, w, h, PdfDrawOptions?) | Filled rectangle. |
DrawAndFillRectangle(double x, y, w, h, PdfDrawOptions?) | Rectangle with fill and stroke. |
DrawCircle(double cx, cy, r, PdfDrawOptions?) | Circle outline. |
FillCircle(double cx, cy, r, PdfDrawOptions?) | Filled circle. |
DrawEllipse(double cx, cy, rx, ry, PdfDrawOptions?) | Ellipse outline. |
FillEllipse(double cx, cy, rx, ry, PdfDrawOptions?) | Filled ellipse. |
DrawPolygon((double, double)[], PdfDrawOptions?) | Polygon outline. |
FillPolygon((double, double)[], PdfDrawOptions?) | Filled polygon. |
BeginPath(PdfDrawOptions?) | Starts path construction; returns PdfPathBuilder. |
Image Methods
| Method | Description |
AddImage(PdfImage, double x, y, w, h) | Places an image at exact size. |
AddImageScaled(PdfImage, double x, y, maxW, maxH) | Places an image preserving aspect ratio. |
Transform & State Methods
| Method | Description |
Translate(double tx, double ty) | Translation transform. |
Scale(double sx, double sy) | Scale transform. |
Rotate(double angleDegrees) | Counter-clockwise rotation. |
Skew(double angleX, double angleY) | Skew (shear) transform. |
SaveGraphicsState() | Saves graphics state (q operator). |
RestoreGraphicsState() | Restores graphics state (Q operator). |
SetAlpha(double strokeAlpha, double fillAlpha) | Sets opacity (0.0β1.0). |
Clipping Methods
| Method | Description |
ClipToRectangle(double x, y, w, h) | Rectangular clip region. |
ClipToCircle(double cx, cy, radius) | Circular clip region. |
ClipToEllipse(double cx, cy, rx, ry) | Elliptical clip region. |
Annotation Methods
| Method | Description |
AddLink(string uri, double x, y, w, h) | Adds a URI hyperlink. |
AddTextAnnotation(double x, y, string contents, ...) | Sticky note. |
AddFreeTextAnnotation(double x, y, w, h, ...) | Inline text annotation. |
AddHighlightAnnotation(...) | Highlight markup. |
AddUnderlineAnnotation(...) | Underline markup. |
AddSquigglyAnnotation(...) | Squiggly underline. |
AddStrikeOutAnnotation(...) | Strikethrough. |
AddStampAnnotation(..., PdfStampIcon, ...) | Stamp annotation. |
Form Field Methods
| Method | Description |
AddTextField(string name, double x, y, w, h, ...) | Text input field. |
AddCheckboxField(string name, double x, y, size, ...) | Checkbox field. |
AddDropdownField(string name, ..., string[] options, ...) | Dropdown list. |
AddListBoxField(string name, ..., string[] options, ...) | List box. |
AddPushButtonField(string name, ...) | Push button. |
AddSignatureField(string name, ...) | Signature placeholder. |
AddTaggedAcroField(PdfStructureElement, PdfAcroField) | Accessible tagged form field. |
Tagged Content (Accessibility) Methods
| Method | Description |
AddTaggedText(PdfStructureElement, string, double x, y, PdfTextOptions?) | Tagged text linked to structure tree. |
AddTaggedTextBlock(PdfStructureElement, IEnumerable<string>, ...) | Tagged multi-line text. |
AddTaggedLink(PdfStructureElement, string uri, string text, ...) | Accessible tagged hyperlink. |
BeginTaggedContent(PdfStructureElement) | Starts tagged content region (returns MCID). |
EndTaggedContent() | Ends tagged content region. |
BeginArtifact(PdfArtifactType) | Starts artifact (non-structural) content. |
EndArtifact() | Ends artifact content. |
AddArtifactText(string, double x, y, PdfArtifactType?, PdfTextOptions?) | Text marked as artifact. |
Pattern, Shading & Layer Methods
| Method | Description |
FillWithShading(PdfShadingPattern, double x, y, w, h) | Fills area with gradient. |
FillWithPattern(PdfTilingPattern, double x, y, w, h) | Fills area with tiling pattern. |
AddFormXObject(PdfFormXObject, double x, y) | Places a form XObject at natural size. |
AddFormXObject(PdfFormXObject, double x, y, w, h) | Places a form XObject scaled. |
BeginOptionalContent(PdfOptionalContentGroup) | Starts layer content. |
EndOptionalContent() | Ends layer content. |
PdfTextOptions
namespace ObviousPDF β Configuration for text rendering.
| Property | Type | Default | Description |
Font | StandardFont | Helvetica | Standard font to use. |
EmbeddedFont | PdfEmbeddedFont? | null | Embedded font (overrides Font). |
FontSize | double | 12 | Size in points. |
Color | PdfColor | Black RGB | Text colour. |
Leading | double? | null (1.2Γ) | Line spacing in points. |
RenderingMode | PdfTextRenderingMode | Fill | Fill, Stroke, FillAndStroke, Invisible, Clip. |
PdfDrawOptions
namespace ObviousPDF β Configuration for vector graphics rendering.
| Property | Type | Default | Description |
StrokeColor | PdfColor | Black | Stroke (outline) colour. |
FillColor | PdfColor | Black | Fill colour. |
LineWidth | double | 1.0 | Line width in points. |
LineCap | PdfLineCap | Butt | Line cap style. |
LineJoin | PdfLineJoin | Miter | Line join style. |
MiterLimit | double | 10.0 | Miter limit for joins. |
DashPattern | double[]? | null | Dash pattern array. |
DashPhase | double | 0 | Dash pattern phase offset. |
StrokeAlpha | double | 1.0 | Stroke opacity (0.0β1.0). |
FillAlpha | double | 1.0 | Fill opacity (0.0β1.0). |
PdfColor
namespace ObviousPDF β Represents a colour in DeviceGray, DeviceRGB, or DeviceCMYK.
// RGB (each 0.0β1.0)
var red = new PdfColor(1.0, 0.0, 0.0);
// Named factory methods
var gray = PdfColor.FromGray(0.5);
var blue = PdfColor.FromRgb(0.0, 0.2, 0.8);
var cyan = PdfColor.FromCmyk(1.0, 0.0, 0.0, 0.0);
Factory Methods
| Method | Description |
new PdfColor(double r, double g, double b) | RGB colour (each 0.0β1.0). |
PdfColor.FromRgb(double r, double g, double b) | RGB colour via factory method. |
PdfColor.FromGray(double gray) | Grayscale (0.0 = black, 1.0 = white). |
PdfColor.FromCmyk(double c, m, y, k) | CMYK colour (each 0.0β1.0). |
Properties
| Property | Type | Description |
ColorSpace | PdfColorSpace | DeviceGray, DeviceRGB, or DeviceCMYK. |
R, G, B | double | RGB components (0.0β1.0). |
Gray | double | Grayscale component (0.0β1.0). |
C, M, Y, K | double | CMYK components (0.0β1.0). |
PdfImage
namespace ObviousPDF β Loads and represents JPEG and PNG images for embedding.
| Factory Method | Description |
PdfImage.FromFile(string path) | Loads a JPEG or PNG image from file. |
PdfImage.FromStream(Stream stream) | Loads from stream. |
PdfImage.FromBytes(byte[] data) | Loads from byte array. |
| Property | Type | Description |
WidthPx | int | Image width in pixels. |
HeightPx | int | Image height in pixels. |
PdfEmbeddedFont
namespace ObviousPDF β Loads TrueType/OpenType fonts for embedding with automatic subsetting.
| Factory Method | Description |
PdfEmbeddedFont.FromFile(string path) | Loads a .ttf/.otf font from file. |
PdfEmbeddedFont.FromStream(Stream stream) | Loads from stream. |
PdfEmbeddedFont.FromBytes(byte[] data) | Loads from byte array. |
StandardFont
namespace ObviousPDF.Fonts β The 14 standard PDF fonts. ObviousPDF auto-embeds SIL OFL substitutes.
| Value | PDF Name | Embedded Substitute |
Helvetica | Helvetica | Sora Regular |
HelveticaBold | Helvetica-Bold | Sora Bold |
HelveticaOblique | Helvetica-Oblique | Sora Italic |
HelveticaBoldOblique | Helvetica-BoldOblique | Sora BoldItalic |
TimesRoman | Times-Roman | CMU Serif Roman |
TimesBold | Times-Bold | CMU Serif Bold |
TimesItalic | Times-Italic | CMU Serif Italic |
TimesBoldItalic | Times-BoldItalic | CMU Serif BoldItalic |
Courier | Courier | CMU Typewriter Regular |
CourierBold | Courier-Bold | CMU Typewriter Bold |
CourierOblique | Courier-Oblique | CMU Typewriter Italic |
CourierBoldOblique | Courier-BoldOblique | CMU Typewriter BoldItalic |
Symbol | Symbol | β |
ZapfDingbats | ZapfDingbats | β |
PageSize
namespace ObviousPDF β Predefined page size tuples (width Γ height in points).
| Constant | Dimensions | Size |
PageSize.Letter | 612 Γ 792 | 8.5 Γ 11 in |
PageSize.Legal | 612 Γ 1008 | 8.5 Γ 14 in |
PageSize.A4 | 595.28 Γ 841.89 | 210 Γ 297 mm |
PageSize.A3 | 841.89 Γ 1190.55 | 297 Γ 420 mm |
PageSize.A5 | 419.53 Γ 595.28 | 148 Γ 210 mm |
PageSize.Tabloid | 792 Γ 1224 | 11 Γ 17 in |
PdfDocumentInfo
namespace ObviousPDF β Document metadata.
| Property | Type | Description |
Title | string? | Document title. |
Author | string? | Author name. |
Subject | string? | Document subject. |
Keywords | string? | Comma-separated keywords. |
Creator | string? | Application that created the content. |
Producer | string | (auto-set) Library that produced the PDF. |
PdfPathBuilder
namespace ObviousPDF β Low-level path construction via BeginPath().
page.BeginPath(new PdfDrawOptions { FillColor = blue })
.MoveTo(300, 440)
.CurveTo(350, 520, 440, 480, 420, 440)
.ClosePath()
.FillAndStroke();
| Method | Returns | Description |
MoveTo(double x, double y) | PdfPathBuilder | Moves to a point. |
LineTo(double x, double y) | PdfPathBuilder | Line to a point. |
CurveTo(x1, y1, x2, y2, x3, y3) | PdfPathBuilder | Cubic BΓ©zier curve. |
ClosePath() | PdfPathBuilder | Closes the current subpath. |
Stroke() | PdfPageBuilder | Strokes the path. |
Fill() | PdfPageBuilder | Fills the path. |
FillAndStroke() | PdfPageBuilder | Fills and strokes. |
PdfStructureElement
namespace ObviousPDF.Accessibility β A node in the PDF structure tree (ISO 32000 Β§14.7.2).
Properties
| Property | Type | Description |
Type | StructureType | The structure type (P, H1, Table, etc.). |
AltText | string? | Alternative text (required for Figures). |
ActualText | string? | Actual replacement text. |
Language | string? | BCP 47 language override. |
Phoneme | string? | Phonemic transcription (PDF 2.0). |
PhoneticAlphabet | PdfPhoneticAlphabet? | IPA or X-SAMPA. |
Scope | PdfTableScope? | Table header scope (Row/Column/Both). |
Expansion | string? | Expanded abbreviation text. |
BBox | double[]? | Bounding box [llx, lly, urx, ury]. Required for Figures. |
Id | string? | Unique ID for header associations. |
Headers | IReadOnlyList<string> | Header IDs for data cells. |
Children | IReadOnlyList<...> | Child elements in reading order. |
OptionalContentGroup | PdfOptionalContentGroup? | Associated OCG. |
Methods
| Method | Returns | Description |
AddChild(StructureType) | PdfStructureElement | Adds child at end. |
AddChild(StructureType, string? altText) | PdfStructureElement | Adds child with alt text. |
AddCaption() | PdfStructureElement | Adds Caption child (Table/Figure). |
AddTableHead() | PdfStructureElement | Adds THead child. |
AddTableBody() | PdfStructureElement | Adds TBody child. |
AddTableFoot() | PdfStructureElement | Adds TFoot child. |
AddTableRow() | PdfStructureElement | Adds TR child. |
AddHeaderCell(PdfTableScope?, string? id, string?) | PdfStructureElement | Adds TH with scope and ID. |
AddDataCell(params string[] headerIds) | PdfStructureElement | Adds TD linked to header IDs. |
AddRuby(bool includeParentheses) | (Ruby, RB, RT) | Ruby annotation group. |
AddTableOfContents() | PdfStructureElement | Adds TOC child. |
InsertChild(int, StructureType) | PdfStructureElement | Inserts at position. |
RemoveChild(PdfStructureElement) | bool | Removes a child. |
StructureType (40+ types)
namespace ObviousPDF.Accessibility β All ISO 32000 structure types.
Document Structure
Document, Sect, Art, Part, Div, BlockQuote, NonStruct
Headings & Paragraphs
H, H1, H2, H3, H4, H5, H6, P
Tables
Table, TR, TH, TD, THead, TBody, TFoot, Caption
Lists
L, LI, Lbl, LBody
Inline Elements
Span, Link, Note, Code, Em, Strong, Quote, Reference
Media & Forms
Figure, Formula, Form
CJK / Ruby
Ruby, RB, RT, RP, Warichu, WT, WP
Table of Contents
TOC, TOCI
PdfAccessibilityChecker
namespace ObviousPDF.Accessibility β Validates 43+ PDF/UA, WCAG 2.2, and ISO 32000 requirements.
var checker = new PdfAccessibilityChecker();
var report = checker.Check(doc);
Console.WriteLine(report.IsFullyCompliant); // true/false
Console.WriteLine(report.ToString()); // Human-readable report
foreach (var issue in report.NonCompliantItems)
Console.WriteLine($" β {issue}");
PdfAccessibilityReport
| Member | Description |
IsFullyCompliant | true if no non-compliant items. |
CompliantItems | List of passing checks. |
NonCompliantItems | List of failing checks with remediation guidance. |
ToString() | Human-readable report text. |
PdfArtifactType
Pagination
Layout
Page
Background
PdfTableScope
Row
Column
Both
PdfPhoneticAlphabet
Ipa
XSampa
PdfColorContrast
Static utility for WCAG contrast checking.
| Method | Description |
CalculateRatio(PdfColor fg, PdfColor bg) | Returns contrast ratio (1.0β21.0). |
MeetsAA(double ratio, bool largeText) | Whether ratio meets WCAG AA (4.5:1 / 3:1). |
MeetsAAA(double ratio, bool largeText) | Whether ratio meets WCAG AAA (7:1 / 4.5:1). |
Annotations
namespace ObviousPDF
PdfAnnotationType
Text
FreeText
Highlight
Underline
Squiggly
StrikeOut
Stamp
PdfStampIcon
Approved
Experimental
NotApproved
AsIs
Expired
NotForPublicRelease
Confidential
Final
Sold
Departmental
ForComment
TopSecret
Draft
ForPublicRelease
PdfAcroField
namespace ObviousPDF β Interactive form field configuration.
var formElement = root.AddChild(StructureType.Form);
var field = new PdfAcroField(PdfAcroFieldType.Text,
"fullName", 72, 675, 250, 20)
{
Tooltip = "Full name (required)",
Required = true
};
page.AddTaggedAcroField(formElement, field);
PdfAcroFieldType
Text
Checkbox
Dropdown
ListBox
PushButton
Signature
RadioButton
PdfEncryption
namespace ObviousPDF β Password and permission settings.
| Property | Type | Default | Description |
UserPassword | string | "" | Open password (empty = no password to open). |
OwnerPassword | string | "" | Full-access password. |
Algorithm | PdfEncryptionAlgorithm | Aes128 | Aes128 or Aes256. |
AllowPrinting | bool | true | Allow printing. |
AllowCopying | bool | true | Allow copy/paste. |
AllowModifying | bool | true | Allow editing. |
AllowAnnotating | bool | true | Allow annotations. |
PdfDigitalSignature
namespace ObviousPDF β PKCS#7/CMS digital signature configuration.
| Property | Type | Default | Description |
Certificate | X509Certificate2 | (required) | Signing certificate with private key. |
Reason | string? | null | Reason for signing. |
Location | string? | null | Signing location. |
ContactInfo | string? | null | Signer contact info. |
SignerName | string? | null | Signer name (defaults to cert CN). |
PageIndex | int | 0 | Page for signature field. |
X, Y | double | 0 | Signature field position. |
Width | double | 200 | Signature field width. |
Height | double | 50 | Signature field height. |
Visual Effects
PdfShadingPattern
namespace ObviousPDF β Axial (linear) and radial gradient definitions.
// Linear gradient
var linear = new PdfShadingPattern(
72, 650, 300, 650,
PdfColor.FromRgb(0.1, 0.3, 0.8),
PdfColor.FromRgb(0.4, 0.9, 0.6));
page.FillWithShading(linear, 72, 620, 228, 60);
// Radial gradient
var radial = PdfShadingPattern.RadialGradient(
440, 650, 0, 70,
PdfColor.FromRgb(1, 0.9, 0.2),
PdfColor.FromRgb(0.9, 0.2, 0.1));
page.FillWithShading(radial, 370, 580, 140, 140);
PdfTilingPattern
namespace ObviousPDF β Repeating tile patterns for fills.
var stripe = new PdfTilingPattern(10, 10);
stripe.FillRectangle(0, 0, 10, 10, lightColor);
stripe.FillRectangle(0, 0, 5, 10, darkColor);
page.FillWithPattern(stripe, 72, 480, 228, 80);
Document Features
PdfOutlineItem
Bookmarks for sidebar navigation.
| Method | Description |
AddChild(string title, int pageIndex) | Adds a child bookmark. |
PdfPageLabelStyle
Decimal
LowerRoman
UpperRoman
LowerAlpha
UpperAlpha
PdfOptionalContentGroup
Toggle-able layers (OCG). Created via doc.CreateOptionalContentGroup(name, visible).
Coordinate System
π PDF Coordinate System
Origin (0, 0) is at the bottom-left corner.
X increases to the right, Y increases upward.
Units are points (1 point = 1/72 inch).
For US Letter (612 Γ 792): Top-left = (0, 792) Β· Bottom-right = (612, 0) Β· 1-inch margins = (72, 720)