π 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. |
PageCount | int | (read-only) | Number of pages currently in the document. |
GenerateAccessibilityReport | bool | false | When true, an internal accessibility report is generated on each Save() or Sign() call. |
LastAccessibilityReport | PdfAccessibilityReport? | (read-only) | The accessibility report from the most recent save, 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. |
EnableAccessibility(string language = "en", string? title = null) | PdfStructureElement | Enables full PDF/UA-1 accessibility with a single call. Sets language, display-doc-title, PDF/UA-1 conformance, tagged PDF, and auto-tagging so AddText, AddTextBlock, and AddImage automatically create structure elements. (ISO 14289-1 Β§7.1) |
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. |
RemovePage(int pageIndex) | void | Removes the page and prunes orphaned structure tree nodes (ISO 14289-1 Β§7.1, Matterhorn 01-003). |
MovePage(int fromIndex, int toIndex) | void | Reorders a page; structure tree resolves correctly at serialization time. |
InsertPages(PdfDocument source, int atIndex) | void | Inserts all pages from source at the given index, merging the source structure tree under a /Part. |
static Merge(IEnumerable<PdfDocument>) | PdfDocument | Merges multiple documents; each source structure tree is grafted under its own /Part in the result. |
Split(IEnumerable<PdfPageRange>) | IReadOnlyList<PdfDocument> | Extracts page ranges into new documents, transferring structure tree nodes. Pages not in any range remain in this document. |
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. |
MeasureTextWidth(string text, PdfTextOptions?) | Measures text advance width in points using the specified font and size. Useful for alignment calculations. |
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. |
AddImage(PdfImage, double x, y, w, h, string altText) | Places an image with alternative text. When auto-tagging is active, a /Figure structure element is created automatically (ISO 14289-1 Β§7.3). |
AddImageScaled(PdfImage, double x, y, maxW, maxH) | Places an image preserving aspect ratio. |
AddImageScaled(PdfImage, double x, y, maxW, maxH, string altText) | Scaled image with alternative text and auto-tagging support. |
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. |
Alignment | PdfTextAlignment | Left | Horizontal text alignment within Width (Left, Center, Right, Justify). Requires Width to be set. |
Width | double? | null | Width of the text layout box in points. The x parameter defines the left edge; alignment is applied within this box. |
Rotation | double | 0 | Rotation angle in degrees, counter-clockwise. Rotates the text and all associated rendering (background, shadow, decoration lines) around the anchor point. Works with AddText, AddTextBlock, AddTaggedText, and AddTaggedTextBlock. |
PdfTextAlignment Enum
Left Center Right Justify
ISO 32000-2 Β§14.8.5.4 (TextAlign attribute). For Justify, word spacing (Tw operator Β§9.3.3) is adjusted so the line fills the width. In AddTextBlock, the last line is left-aligned.
Text Rotation
// 45-degree diagonal text
page.AddText("Diagonal", 200, 400, new PdfTextOptions { Rotation = 45 });
// Vertical text β reads bottom to top
page.AddText("Vertical", 400, 300, new PdfTextOptions { Rotation = 90, FontSize = 14 });
// White text on a black background
page.AddText("White on Black", 72, 350, new PdfTextOptions
{
Color = PdfColor.FromRgb(1, 1, 1),
BackgroundColor = PdfColor.Black,
FontSize = 16
});
// Rotation with background β the background rectangle rotates with the text
page.AddText("Rotated highlight", 200, 500, new PdfTextOptions
{
Rotation = 30,
BackgroundColor = PdfColor.FromRgb(1.0, 1.0, 0.0),
FontSize = 14
});
Implemented via PDF CTM (cm operator, ISO 32000 Β§8.3.4) wrapped in a q/Q graphics-state pair. Background rectangles, drop shadows, and decoration lines all rotate with the text. To rotate shapes or images, use SaveGraphicsState() / Rotate() / RestoreGraphicsState() instead.
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. |
| Method | Returns | Description |
MeasureTextWidth(string text, double fontSize) | double | Measures the advance width of text in points at the given font size. Uses TrueType hmtx glyph metrics. |
| Property | Type | Description |
FontFamily | string | Font family name (e.g. "Roboto"). |
PostScriptName | string | PostScript name (e.g. "Roboto-Regular"). |
UnitsPerEm | int | Units-per-em for scaling metrics. |
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.
β οΈ Disclaimer: The automated accessibility checker and its reports are provided solely to assist in the assessment of document accessibility. They are not a comprehensive accessibility audit. To confirm that WCAG or PDF/UA standards are fully met, human assessment by an accessibility specialist is recommended.
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}");
Automatic Report Generation (v1.3.0)
Enable accessibility report generation on every Save() or Sign() call:
doc.GenerateAccessibilityReport = true;
doc.Save("output.pdf");
if (doc.LastAccessibilityReport != null)
Console.WriteLine(doc.LastAccessibilityReport.ToString());
{
"accessible": true,
"generateAccessibilityReport": true,
"pages": [ ... ]
}
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 (includes disclaimer). |
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.
Requires an X509Certificate2 with an exportable private key (.pfx/.p12).
See the Certificate Setup Guide
for instructions on creating a self-signed certificate or obtaining one from a trusted CA.
| Property | Type | Default | Description |
Certificate | X509Certificate2 | (required) | Signing certificate with exportable private key. Load from a .pfx/.p12 file using X509Certificate2 or from the Windows certificate store. |
Reason | string? | null | Reason for signing (e.g. "I approve this document"). |
Location | string? | null | Geographic location where the document was signed. |
ContactInfo | string? | null | Signer contact info (e.g. email address). |
SignerName | string? | null | Signer display name. Defaults to the certificate CN when null. |
FieldName | string | "Signature1" | Name of the signature field in the AcroForm. Must be unique within the document. |
PageIndex | int | 0 | Zero-based page index for the signature field. |
X, Y | double | 0 | Signature field position in points (lower-left origin). |
Width | double | 200 | Signature field width in points. |
Height | double | 50 | Signature field height in points. |
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)
JSON Renderer β ObviousPDF.Json
namespace ObviousPDF.Json β JSON-to-PDF pipeline. Accepts a JSON document conforming to the ObviousPDF JSON schema and produces a tagged, accessible PDF binary.
using ObviousPDF.Json;
// Render JSON string β PDF bytes
byte[] pdf = PdfJsonRenderer.Render(jsonString);
// Render from a .json file path β PDF bytes
byte[] pdf = PdfJsonRenderer.RenderFromFile("document.json");
// Build PdfDocument for further manipulation
PdfDocument doc = PdfJsonRenderer.BuildDocument(jsonString);
doc.Save("output.pdf");
PdfJsonRenderer β Static Methods
| Method | Returns | Description |
Render(string json) | byte[] | Render a JSON string to a PDF byte array. |
RenderFromFile(string path) | byte[] | Load a .json file and render it to a PDF byte array. |
BuildDocument(string json) | PdfDocument | Parse the JSON and build a PdfDocument without saving, so you can add content programmatically before calling Save(). |
JSON Document Root Object
The JSON document root is an object with 15 top-level keys. Only pages is required.
| Key | Type | Description |
pages | array | Required. Array of page objects. At least one page. |
coordinateOrigin | string | "bottomLeft" (default, native PDF) or "topLeft" (Y increases downward). Overridable per page. |
tagged | boolean | Enable tagged PDF for accessibility. Default: false. |
accessible | boolean | Shorthand for full PDF/UA-1 accessibility. Enables tagged PDF, PDF/UA-1 conformance, display-doc-title, and auto-tagging (text β <P>, images β <Figure>). No structureTree or structureId needed. Default: false. New in v1.2.0. |
document | object | Metadata, pdfVersion, conformance, encryption, signature, linearize, xref settings. |
fonts | array | Font library. Referenced via options.fontRef. |
images | array | Image library. Referenced via imageRef on image elements. |
formXObjects | array | Reusable FormXObject templates. Referenced via ref. |
layers | array | OCG layer declarations. Referenced via layerRef. |
shadings | array | Axial/radial gradient declarations. Referenced via shadingId. |
patterns | array | Tiling pattern declarations. Referenced via patternId. |
attachments | array | Embedded file attachments. |
outlines | array | Bookmark tree (nestable via children). |
pageLabels | array | Page label ranges. |
structureTree | object | Logical structure tree root. Required when tagged: true. |
roleMappings | array | Custom structure type β standard type mappings. |
document Settings Object
| Property | Type / Default | Description |
info.title | string | Document title. |
info.author | string | Document author. |
info.subject | string | Document subject. |
info.keywords | string | Keywords. |
info.creator | string | Creating application. |
language | string | BCP 47 tag (e.g. "en-US"). Required for PDF/UA. |
displayDocTitle | boolean / false | Show title in viewer. Required for PDF/UA. |
pdfVersion | string | "1.7" or "2.0". Auto-inferred when absent. |
conformance.pdfA | string | "pdfA1B" / "pdfA2B" / "pdfA3B" |
conformance.pdfUa | string | "PdfUA1" / "PdfUA2" |
linearize | boolean / false | Fast web view. |
useCrossReferenceStreams | boolean / false | Compact xref streams. |
useObjectStreams | boolean / false | Compressed object streams (reduces file size). |
encryption | object | userPassword, ownerPassword, algorithm ("Aes128"/"Aes256"), allowPrinting, allowCopying, allowModifying, allowAnnotating. |
signature | object | certificatePath, certificatePassword, reason, location, contactInfo, signerName, fieldName, pageIndex, x, y, width (200), height (50). |
Page Object
| Property | Type | Description |
size | string | "Letter" (612Γ792) Β· "Legal" (612Γ1008) Β· "A4" (595Γ842) Β· "A3" (842Γ1191) Β· "A5" (420Γ595) Β· "Tabloid" (792Γ1224) |
width / height | number | Custom page size in points (mutually exclusive with size). |
coordinateOrigin | string | Page-level override: "topLeft" / "bottomLeft". |
content | array | Content elements for this page. |
Content Element Types
Every element is identified by a required "type" string. All elements additionally accept structureId, artifact, artifactType, and artifactSubtype for accessibility and artifact marking.
| type | Category | Key Properties |
text | Text | text, x, y, options (textOptions) |
textBlock | Text | lines (string[]), x, y, options |
image | Image | imageRef or source, x, y, width, height, scaleMode ("exact"/"fit"/"stretch"), altText (string β alternative text for accessibility; auto-creates <Figure> when accessible: true) |
line | Shape | x1, y1, x2, y2, drawOptions |
rectangle | Shape | x, y, width, height, mode, drawOptions |
circle | Shape | cx, cy, r, mode, drawOptions |
ellipse | Shape | cx, cy, rx, ry, mode, drawOptions |
polygon | Shape | points ([[x,y],...]), mode, drawOptions |
path | Shape | operations (moveTo/lineTo/curveTo/closePath), render, drawOptions |
link | Annotation | uri, x, y, width, height |
textAnnotation | Annotation | x, y, contents, color, open |
freeTextAnnotation | Annotation | x, y, width, height, contents, options, color |
markupAnnotation | Annotation | markupType (highlight/underline/squiggly/strikeOut), x, y, width, height, color |
stampAnnotation | Annotation | icon, x, y, width, height, color |
formXObject | Template | ref (library id), x, y, width, height |
textField | Form | name, position, tooltip, defaultValue, multiline, password, maxLength, fontSize, readonly, required |
checkboxField | Form | name, position, tooltip, checked, readonly, required |
dropdownField | Form | name, position, tooltip, options (string[]), selectedIndex, fontSize, readonly, required |
listBoxField | Form | name, position, tooltip, options (string[]), selectedIndex, fontSize, readonly, required |
pushButtonField | Form | name, position, tooltip, label |
signatureField | Form | name, position, tooltip |
transform | Composite | operation (translate/scale/rotate/skew/matrix), params, content[] |
clip | Composite | shape (rectangle/circle/ellipse), shape params, content[] |
layer | Composite | layerRef, content[] |
shading | Gradient | shadingId, x, y, width, height |
tilingPattern | Pattern | patternId, x, y, width, height |
alpha | Composite | strokeAlpha (0β1), fillAlpha (0β1), content[] |
Text Options Object
| Property | Type / Default | Description |
fontRef | string | Font library id. |
fontSize | number / 12 | Size in points. |
color | color | Fill color. |
leading | number | Line spacing in points. Default: fontSize Γ 1.2. |
renderingMode | string / "fill" | "fill" Β· "stroke" Β· "fillAndStroke" Β· "invisible" |
alignment | string / "left" | "left" Β· "center" Β· "right" Β· "justify" |
width | number | Max width for wrapping/alignment. |
decoration | string[] | "underline" Β· "strikeOut" Β· "overline" |
superscript / subscript | boolean / false | Super/subscript rendering. |
outlineColor / outlineWidth | color / number | Text stroke effect. |
backgroundColor | color | Highlight behind text. |
shadowColor / shadowOffsetX / shadowOffsetY | color / number | Drop shadow. |
rotation | number / 0 | Degrees, counter-clockwise. |
Draw Options Object
| Property | Type / Default | Description |
strokeColor / fillColor | color | Stroke and fill colors. |
lineWidth | number / 1.0 | Stroke width in points. |
lineCap | string / "butt" | "butt" Β· "round" Β· "projecting" |
lineJoin | string / "miter" | "miter" Β· "round" Β· "bevel" |
dashPattern | number[] | e.g. [5, 3] = 5pt dash, 3pt gap. |
dashPhase | number / 0 | Dash pattern phase offset. |
strokeAlpha / fillAlpha | number / 1.0 | Opacity (0.0β1.0). |
Color Format
Any property accepting a color can be: a named string ("black", "white", "red", "green", "blue"), an RGB object {"r":0β1,"g":0β1,"b":0β1}, a gray object {"gray":0β1}, or a CMYK object {"c":0β1,"m":0β1,"y":0β1,"k":0β1}.
Additional Resources
π Download JSON Schema (draft-07)
π€ LLM Guide β JSON Renderer
ποΈ Form 1040 Example
β‘ Easy Accessibility
XML Renderer β ObviousPDF.Xml
namespace ObviousPDF.Xml β XML-to-PDF pipeline. Accepts an XML document conforming to the ObviousPDF XML Schema and produces a tagged, accessible PDF. Internally deserializes to the shared model and delegates to the JSON renderer pipeline.
using ObviousPDF.Xml;
// Render XML string β PDF file
PdfXmlRenderer.Render(xmlString, "output.pdf");
// Render from an XML file
PdfXmlRenderer.RenderFromFile("input.xml", "output.pdf");
// Build PdfDocument for further manipulation
PdfDocument doc = PdfXmlRenderer.BuildDocument(xmlString);
doc.Save("output.pdf");
PdfXmlRenderer β Static Methods
| Method | Returns | Description |
Render(string xml, string outputPath) | void | Render an XML string to a PDF file. |
Render(string xml, Stream outputStream) | void | Render an XML string to a stream. |
RenderFromFile(string xmlPath, string outputPath) | void | Load an .xml file and render it to a PDF file. Resolves relative paths from the XML file's directory. |
BuildDocument(string xml) | PdfDocument | Parse XML and build a PdfDocument without saving. |
BuildDocumentFromFile(string xmlPath) | PdfDocument | Load an .xml file and build a PdfDocument without saving. |
RenderWithReport(string xml, string outputPath) | PdfXmlRenderResult | Render to file and return an accessibility report. |
RenderWithReport(string xml, Stream outputStream) | PdfXmlRenderResult | Render to stream and return an accessibility report. |
PdfXmlRenderer β Instance Methods
Create an instance with PdfXmlRendererOptions for configurable rendering.
| Method | Returns | Description |
RenderToFile(string xml, string outputPath) | void | Render using instance options to a file. |
RenderToStream(string xml, Stream outputStream) | void | Render using instance options to a stream. |
RenderToFileWithReport(string xml, string outputPath) | PdfXmlRenderResult | Render to file with accessibility report. |
RenderToStreamWithReport(string xml, Stream outputStream) | PdfXmlRenderResult | Render to stream with accessibility report. |
PdfXmlRendererOptions
| Property | Type / Default | Description |
BasePath | string / CWD | Base directory for resolving relative file paths in font, image, and attachment entries. |
ImageFetchTimeoutSeconds | int / 10 | Timeout in seconds for fetching URL-based images. |
MaxRedirects | int / 3 | Maximum HTTP redirects for URL images. |
AllowInsecureImageUrls | bool / false | Skip SSL certificate validation for URL images. |
GenerateAccessibilityReport | bool / false | Generate an accessibility report after building the PDF. |
PdfXmlRenderResult
| Property | Type | Description |
AccessibilityReport | PdfAccessibilityReport? | The accessibility report, or null if not enabled. |
PdfXmlValidator
Validate an XML document without rendering it.
| Method | Returns | Description |
Validate(string xml) | PdfXmlValidationResult | Validates the XML by deserializing and running all XV001βXV025 rules. Returns errors and warnings. |
PdfXmlValidationResult
| Property | Type | Description |
IsValid | bool | true when there are no errors. |
Errors | IReadOnlyList<PdfXmlValidationItem> | Validation errors (document cannot be rendered). |
Warnings | IReadOnlyList<PdfXmlValidationItem> | Validation warnings (document can be rendered but may have issues). |
PdfXmlRenderException
Thrown when XML-to-PDF rendering fails. Inherits from Exception.
| Property | Type | Description |
ValidationResult | PdfXmlValidationResult? | The validation result that caused the exception, if any. |
XML Namespace
All elements belong to https://obviouspdf.com/schemas/xml/1.0. The XML schema mirrors the JSON schema β the same document model, content elements, and structure tree are supported via XML element/attribute syntax.
<Document xmlns="https://obviouspdf.com/schemas/xml/1.0">
<Pages>
<Page size="Letter">
<Content>
<Text x="72" y="720">Hello, ObviousPDF!</Text>
</Content>
</Page>
</Pages>
</Document>
CSV Renderer β ObviousPDF.Csv
namespace ObviousPDF.Csv β Convert section-based CSV documents to tagged, accessible PDFs. The CSV pipeline internally delegates to the JSON renderer, ensuring identical behavior across all three input formats.
PdfCsvRenderer β Static Methods
| Method | Returns | Description |
Render(string csv, string outputPath) | void | Render a CSV string to a PDF file. |
Render(string csv, Stream outputStream) | void | Render a CSV string to a stream. |
RenderFromFile(string csvPath, string outputPath) | void | Load a .csv file and render it to a PDF file. Resolves relative paths from the CSV file's directory. |
BuildDocument(string csv) | PdfDocument | Parse CSV and build a PdfDocument without saving. |
BuildDocumentFromFile(string csvPath) | PdfDocument | Load a .csv file and build a PdfDocument without saving. |
CreateFormTemplate(string documentTitle = "New Form", int pageCount = 1) | string | Create a starter CSV template for form-based documents with sample document settings, fonts, and page sections. |
RenderWithReport(string csv, string outputPath) | PdfCsvRenderResult | Render to file and return an accessibility report. |
RenderWithReport(string csv, Stream outputStream) | PdfCsvRenderResult | Render to stream and return an accessibility report. |
PdfCsvRenderer β Instance Methods
Create an instance with PdfCsvRendererOptions for configurable rendering.
| Method | Returns | Description |
RenderToFile(string csv, string outputPath) | void | Render using instance options to a file. |
RenderToStream(string csv, Stream outputStream) | void | Render using instance options to a stream. |
RenderToFileWithReport(string csv, string outputPath) | PdfCsvRenderResult | Render to file with accessibility report. |
RenderToStreamWithReport(string csv, Stream outputStream) | PdfCsvRenderResult | Render to stream with accessibility report. |
PdfCsvRendererOptions
| Property | Type / Default | Description |
BasePath | string / CWD | Base directory for resolving relative file paths in font, image, and attachment entries. |
ImageFetchTimeoutSeconds | int / 10 | Timeout in seconds for fetching URL-based images. |
MaxRedirects | int / 3 | Maximum HTTP redirects for URL images. |
AllowInsecureImageUrls | bool / false | Skip SSL certificate validation for URL images. |
GenerateAccessibilityReport | bool / false | Generate an accessibility report after building the PDF. |
PdfCsvRenderResult
| Property | Type | Description |
AccessibilityReport | PdfAccessibilityReport? | The accessibility report, or null if not enabled. |
PdfCsvValidator
Validate a CSV document without rendering it.
| Method | Returns | Description |
Validate(string csv) | PdfCsvValidationResult | Validates the CSV by deserializing and running all CV001βCV025 rules. Returns errors and warnings. |
PdfCsvValidationResult
| Property | Type | Description |
IsValid | bool | true when there are no errors. |
Errors | IReadOnlyList<PdfCsvValidationItem> | Validation errors (document cannot be rendered). |
Warnings | IReadOnlyList<PdfCsvValidationItem> | Validation warnings (document can be rendered but may have issues). |
PdfCsvRenderException
Thrown when CSV-to-PDF rendering fails. Inherits from Exception.
| Property | Type | Description |
ValidationResult | PdfCsvValidationResult? | The validation result that caused the exception, if any. |
CSV Format
The CSV format uses section headers in square brackets ([DOCUMENT], [FONTS], [PAGE 1], etc.) with column-header rows per section. RFC 4180 compliant, auto-detects comma or tab delimiters. Pipe (|) is used for multi-value fields. Base64 data supports continuation rows with + prefix.
[PAGE 1]
type,x,y,text
text,72,720,Hello ObviousPDF!