πŸ“– 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.

Creating a Document
var doc = new PdfDocument();
doc.Info.Title = "My Document";
doc.Language = "en-US";
doc.Save("output.pdf");

Properties

PropertyTypeDefaultDescription
InfoPdfDocumentInfo(empty)Document metadata (title, author, subject, etc.)
Languagestring?nullBCP 47 language tag (e.g. "en-US"). Required for PDF/UA.
DisplayDocTitleboolfalseShow title in viewer title bar. Required for PDF/UA.
PdfVersionstring?nullExplicit PDF version (e.g. "2.0"). Auto-inferred when null.
PdfAConformancePdfAConformanceLevelNonePDF/A archival conformance level.
PdfUaConformancePdfUaConformanceLevelNonePDF/UA accessibility conformance level.
UseCrossReferenceStreamsboolfalseUse compact xref streams (PDF 1.5+).
UseObjectStreamsboolfalsePack objects in compressed streams (PDF 1.5+).
EncryptionPdfEncryption?nullEncryption settings (AES-128 or AES-256).
LinearizeboolfalseEnable fast web view (linearized PDF).
IsTaggedbool(read-only)Whether tagged PDF is enabled.
StructureTreeRootPdfStructureElement?(read-only)Root of the structure tree, or null.
PageCountint(read-only)Number of pages currently in the document.
GenerateAccessibilityReportboolfalseWhen true, an internal accessibility report is generated on each Save() or Sign() call.
LastAccessibilityReportPdfAccessibilityReport?(read-only)The accessibility report from the most recent save, or null.

Methods

MethodReturnsDescription
AddPage(double width = 612, double height = 792)PdfPageBuilderAdds a page with custom dimensions (points).
AddPage((double, double) pageSize)PdfPageBuilderAdds a page using a PageSize constant.
EnableTaggedPdf()PdfStructureElementEnables tagged PDF; returns root Document element.
EnableAccessibility(string language = "en", string? title = null)PdfStructureElementEnables 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)voidMaps custom structure type to standard type.
AddOutline(string title, int pageIndex)PdfOutlineItemAdds a top-level bookmark.
AddPageLabels(int, PdfPageLabelStyle, string?, int)PdfPageLabelAdds a page label range.
CreateFormXObject(double w, double h)PdfFormXObjectCreates a reusable form XObject.
CreateOptionalContentGroup(string, bool)PdfOptionalContentGroupCreates an OCG (layer).
AddAssociatedFile(string, string, byte[], ...)PdfAssociatedFileAttaches a document-level file.
CreateDocumentPartRoot()PdfDocumentPartCreates root for document part hierarchy.
Save(string filePath)voidWrites PDF to a file path.
Save(Stream stream)voidWrites PDF to any stream.
Sign(string filePath, PdfDigitalSignature)voidSaves and digitally signs the PDF.
RemovePage(int pageIndex)voidRemoves the page and prunes orphaned structure tree nodes (ISO 14289-1 Β§7.1, Matterhorn 01-003).
MovePage(int fromIndex, int toIndex)voidReorders a page; structure tree resolves correctly at serialization time.
InsertPages(PdfDocument source, int atIndex)voidInserts all pages from source at the given index, merging the source structure tree under a /Part.
static Merge(IEnumerable<PdfDocument>)PdfDocumentMerges 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.

PdfPageRange

namespace ObviousPDF β€” A readonly struct representing a contiguous range of zero-based page indices. Used with PdfDocument.Split.

Usage
// Pages 0-2 into doc1, pages 3-4 into doc2
var parts = doc.Split(new[] {
    new PdfPageRange(0, 3),
    PdfPageRange.FromStartEnd(3, 4)
});

Properties

PropertyTypeDescription
StartIndexintZero-based index of the first page in the range.
CountintNumber of pages in the range (β‰₯ 1).
EndIndexExclusiveintExclusive end index (StartIndex + Count).

Constructor & Factory

SignatureDescription
PdfPageRange(int startIndex, int count)Range starting at startIndex covering count pages.
static FromStartEnd(int start, int endInclusive)Range from inclusive start to inclusive end index.

PdfPageBuilder

namespace ObviousPDF β€” Fluent API for adding content to a single PDF page.

Text Methods

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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.

PropertyTypeDefaultDescription
FontStandardFontHelveticaStandard font to use.
EmbeddedFontPdfEmbeddedFont?nullEmbedded font (overrides Font).
FontSizedouble12Size in points.
ColorPdfColorBlack RGBText colour.
Leadingdouble?null (1.2Γ—)Line spacing in points.
RenderingModePdfTextRenderingModeFillFill, Stroke, FillAndStroke, Invisible, Clip.
AlignmentPdfTextAlignmentLeftHorizontal text alignment within Width (Left, Center, Right, Justify). Requires Width to be set.
Widthdouble?nullWidth of the text layout box in points. The x parameter defines the left edge; alignment is applied within this box.
Rotationdouble0Rotation 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

Rotation Examples
// 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.

PropertyTypeDefaultDescription
StrokeColorPdfColorBlackStroke (outline) colour.
FillColorPdfColorBlackFill colour.
LineWidthdouble1.0Line width in points.
LineCapPdfLineCapButtLine cap style.
LineJoinPdfLineJoinMiterLine join style.
MiterLimitdouble10.0Miter limit for joins.
DashPatterndouble[]?nullDash pattern array.
DashPhasedouble0Dash pattern phase offset.
StrokeAlphadouble1.0Stroke opacity (0.0–1.0).
FillAlphadouble1.0Fill opacity (0.0–1.0).

PdfColor

namespace ObviousPDF β€” Represents a colour in DeviceGray, DeviceRGB, or DeviceCMYK.

Creating Colours
// 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

MethodDescription
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

PropertyTypeDescription
ColorSpacePdfColorSpaceDeviceGray, DeviceRGB, or DeviceCMYK.
R, G, BdoubleRGB components (0.0–1.0).
GraydoubleGrayscale component (0.0–1.0).
C, M, Y, KdoubleCMYK components (0.0–1.0).

PdfImage

namespace ObviousPDF β€” Loads and represents JPEG and PNG images for embedding.

Factory MethodDescription
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.
PropertyTypeDescription
WidthPxintImage width in pixels.
HeightPxintImage height in pixels.

PdfEmbeddedFont

namespace ObviousPDF β€” Loads TrueType/OpenType fonts for embedding with automatic subsetting.

Factory MethodDescription
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.
MethodReturnsDescription
MeasureTextWidth(string text, double fontSize)doubleMeasures the advance width of text in points at the given font size. Uses TrueType hmtx glyph metrics.
PropertyTypeDescription
FontFamilystringFont family name (e.g. "Roboto").
PostScriptNamestringPostScript name (e.g. "Roboto-Regular").
UnitsPerEmintUnits-per-em for scaling metrics.

StandardFont

namespace ObviousPDF.Fonts β€” The 14 standard PDF fonts. ObviousPDF auto-embeds SIL OFL substitutes.

ValuePDF NameEmbedded Substitute
HelveticaHelveticaSora Regular
HelveticaBoldHelvetica-BoldSora Bold
HelveticaObliqueHelvetica-ObliqueSora Italic
HelveticaBoldObliqueHelvetica-BoldObliqueSora BoldItalic
TimesRomanTimes-RomanCMU Serif Roman
TimesBoldTimes-BoldCMU Serif Bold
TimesItalicTimes-ItalicCMU Serif Italic
TimesBoldItalicTimes-BoldItalicCMU Serif BoldItalic
CourierCourierCMU Typewriter Regular
CourierBoldCourier-BoldCMU Typewriter Bold
CourierObliqueCourier-ObliqueCMU Typewriter Italic
CourierBoldObliqueCourier-BoldObliqueCMU Typewriter BoldItalic
SymbolSymbolβ€”
ZapfDingbatsZapfDingbatsβ€”

PageSize

namespace ObviousPDF β€” Predefined page size tuples (width Γ— height in points).

ConstantDimensionsSize
PageSize.Letter612 Γ— 7928.5 Γ— 11 in
PageSize.Legal612 Γ— 10088.5 Γ— 14 in
PageSize.A4595.28 Γ— 841.89210 Γ— 297 mm
PageSize.A3841.89 Γ— 1190.55297 Γ— 420 mm
PageSize.A5419.53 Γ— 595.28148 Γ— 210 mm
PageSize.Tabloid792 Γ— 122411 Γ— 17 in

PdfDocumentInfo

namespace ObviousPDF β€” Document metadata.

PropertyTypeDescription
Titlestring?Document title.
Authorstring?Author name.
Subjectstring?Document subject.
Keywordsstring?Comma-separated keywords.
Creatorstring?Application that created the content.
Producerstring(auto-set) Library that produced the PDF.

PdfFormXObject

namespace ObviousPDF β€” Reusable content stream for headers, footers, watermarks.

Usage
var header = doc.CreateFormXObject(612, 35);
header.FillRectangle(0, 0, 612, 35, opts);
header.AddText("Header Text", 72, 10, textOpts);

// Place on every page
page.AddFormXObject(header, 0, 757);
MethodDescription
AddText(string, double x, y, PdfTextOptions?)Adds text to the form.
DrawLine(...)Draws a line.
DrawRectangle(...)Draws a rectangle.
FillRectangle(...)Fills a rectangle.

PdfPathBuilder

namespace ObviousPDF β€” Low-level path construction via BeginPath().

BΓ©zier Curve Path
page.BeginPath(new PdfDrawOptions { FillColor = blue })
    .MoveTo(300, 440)
    .CurveTo(350, 520, 440, 480, 420, 440)
    .ClosePath()
    .FillAndStroke();
MethodReturnsDescription
MoveTo(double x, double y)PdfPathBuilderMoves to a point.
LineTo(double x, double y)PdfPathBuilderLine to a point.
CurveTo(x1, y1, x2, y2, x3, y3)PdfPathBuilderCubic BΓ©zier curve.
ClosePath()PdfPathBuilderCloses the current subpath.
Stroke()PdfPageBuilderStrokes the path.
Fill()PdfPageBuilderFills the path.
FillAndStroke()PdfPageBuilderFills and strokes.

PdfStructureElement

namespace ObviousPDF.Accessibility β€” A node in the PDF structure tree (ISO 32000 Β§14.7.2).

Properties

PropertyTypeDescription
TypeStructureTypeThe structure type (P, H1, Table, etc.).
AltTextstring?Alternative text (required for Figures).
ActualTextstring?Actual replacement text.
Languagestring?BCP 47 language override.
Phonemestring?Phonemic transcription (PDF 2.0).
PhoneticAlphabetPdfPhoneticAlphabet?IPA or X-SAMPA.
ScopePdfTableScope?Table header scope (Row/Column/Both).
Expansionstring?Expanded abbreviation text.
BBoxdouble[]?Bounding box [llx, lly, urx, ury]. Required for Figures.
Idstring?Unique ID for header associations.
HeadersIReadOnlyList<string>Header IDs for data cells.
ChildrenIReadOnlyList<...>Child elements in reading order.
OptionalContentGroupPdfOptionalContentGroup?Associated OCG.

Methods

MethodReturnsDescription
AddChild(StructureType)PdfStructureElementAdds child at end.
AddChild(StructureType, string? altText)PdfStructureElementAdds child with alt text.
AddCaption()PdfStructureElementAdds Caption child (Table/Figure).
AddTableHead()PdfStructureElementAdds THead child.
AddTableBody()PdfStructureElementAdds TBody child.
AddTableFoot()PdfStructureElementAdds TFoot child.
AddTableRow()PdfStructureElementAdds TR child.
AddHeaderCell(PdfTableScope?, string? id, string?)PdfStructureElementAdds TH with scope and ID.
AddDataCell(params string[] headerIds)PdfStructureElementAdds TD linked to header IDs.
AddRuby(bool includeParentheses)(Ruby, RB, RT)Ruby annotation group.
AddTableOfContents()PdfStructureElementAdds TOC child.
InsertChild(int, StructureType)PdfStructureElementInserts at position.
RemoveChild(PdfStructureElement)boolRemoves 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.
Usage
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:

C# API
doc.GenerateAccessibilityReport = true;
doc.Save("output.pdf");

if (doc.LastAccessibilityReport != null)
    Console.WriteLine(doc.LastAccessibilityReport.ToString());
JSON Pipeline
{
  "accessible": true,
  "generateAccessibilityReport": true,
  "pages": [ ... ]
}

PdfAccessibilityReport

MemberDescription
IsFullyComplianttrue if no non-compliant items.
CompliantItemsList of passing checks.
NonCompliantItemsList 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.

MethodDescription
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.

Tagged Form Field
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.

PropertyTypeDefaultDescription
UserPasswordstring""Open password (empty = no password to open).
OwnerPasswordstring""Full-access password.
AlgorithmPdfEncryptionAlgorithmAes128Aes128 or Aes256.
AllowPrintingbooltrueAllow printing.
AllowCopyingbooltrueAllow copy/paste.
AllowModifyingbooltrueAllow editing.
AllowAnnotatingbooltrueAllow 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.

PropertyTypeDefaultDescription
CertificateX509Certificate2(required)Signing certificate with exportable private key. Load from a .pfx/.p12 file using X509Certificate2 or from the Windows certificate store.
Reasonstring?nullReason for signing (e.g. "I approve this document").
Locationstring?nullGeographic location where the document was signed.
ContactInfostring?nullSigner contact info (e.g. email address).
SignerNamestring?nullSigner display name. Defaults to the certificate CN when null.
FieldNamestring"Signature1"Name of the signature field in the AcroForm. Must be unique within the document.
PageIndexint0Zero-based page index for the signature field.
X, Ydouble0Signature field position in points (lower-left origin).
Widthdouble200Signature field width in points.
Heightdouble50Signature field height in points.

Visual Effects

PdfShadingPattern

namespace ObviousPDF β€” Axial (linear) and radial gradient definitions.

Gradients
// 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.

Tiling Pattern
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.

MethodDescription
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).

Conformance Levels

PdfAConformanceLevel (Archival)

None PdfA1B PdfA2B PdfA3B

PdfUaConformanceLevel (Accessibility)

None PdfUA1 PdfUA2

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)

πŸ“₯ Full Markdown Reference

This HTML page covers all public API surface. For a plain-text version with all overloads, download the full API Reference markdown file.

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.

PdfJsonRenderer β€” Three Entry Points
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

MethodReturnsDescription
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)PdfDocumentParse 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.

KeyTypeDescription
pagesarrayRequired. Array of page objects. At least one page.
coordinateOriginstring"bottomLeft" (default, native PDF) or "topLeft" (Y increases downward). Overridable per page.
taggedbooleanEnable tagged PDF for accessibility. Default: false.
accessiblebooleanShorthand 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.
documentobjectMetadata, pdfVersion, conformance, encryption, signature, linearize, xref settings.
fontsarrayFont library. Referenced via options.fontRef.
imagesarrayImage library. Referenced via imageRef on image elements.
formXObjectsarrayReusable FormXObject templates. Referenced via ref.
layersarrayOCG layer declarations. Referenced via layerRef.
shadingsarrayAxial/radial gradient declarations. Referenced via shadingId.
patternsarrayTiling pattern declarations. Referenced via patternId.
attachmentsarrayEmbedded file attachments.
outlinesarrayBookmark tree (nestable via children).
pageLabelsarrayPage label ranges.
structureTreeobjectLogical structure tree root. Required when tagged: true.
roleMappingsarrayCustom structure type β†’ standard type mappings.

document Settings Object

PropertyType / DefaultDescription
info.titlestringDocument title.
info.authorstringDocument author.
info.subjectstringDocument subject.
info.keywordsstringKeywords.
info.creatorstringCreating application.
languagestringBCP 47 tag (e.g. "en-US"). Required for PDF/UA.
displayDocTitleboolean / falseShow title in viewer. Required for PDF/UA.
pdfVersionstring"1.7" or "2.0". Auto-inferred when absent.
conformance.pdfAstring"pdfA1B" / "pdfA2B" / "pdfA3B"
conformance.pdfUastring"PdfUA1" / "PdfUA2"
linearizeboolean / falseFast web view.
useCrossReferenceStreamsboolean / falseCompact xref streams.
useObjectStreamsboolean / falseCompressed object streams (reduces file size).
encryptionobjectuserPassword, ownerPassword, algorithm ("Aes128"/"Aes256"), allowPrinting, allowCopying, allowModifying, allowAnnotating.
signatureobjectcertificatePath, certificatePassword, reason, location, contactInfo, signerName, fieldName, pageIndex, x, y, width (200), height (50).

Page Object

PropertyTypeDescription
sizestring"Letter" (612Γ—792) Β· "Legal" (612Γ—1008) Β· "A4" (595Γ—842) Β· "A3" (842Γ—1191) Β· "A5" (420Γ—595) Β· "Tabloid" (792Γ—1224)
width / heightnumberCustom page size in points (mutually exclusive with size).
coordinateOriginstringPage-level override: "topLeft" / "bottomLeft".
contentarrayContent 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.

typeCategoryKey Properties
textTexttext, x, y, options (textOptions)
textBlockTextlines (string[]), x, y, options
imageImageimageRef or source, x, y, width, height, scaleMode ("exact"/"fit"/"stretch"), altText (string β€” alternative text for accessibility; auto-creates <Figure> when accessible: true)
lineShapex1, y1, x2, y2, drawOptions
rectangleShapex, y, width, height, mode, drawOptions
circleShapecx, cy, r, mode, drawOptions
ellipseShapecx, cy, rx, ry, mode, drawOptions
polygonShapepoints ([[x,y],...]), mode, drawOptions
pathShapeoperations (moveTo/lineTo/curveTo/closePath), render, drawOptions
linkAnnotationuri, x, y, width, height
textAnnotationAnnotationx, y, contents, color, open
freeTextAnnotationAnnotationx, y, width, height, contents, options, color
markupAnnotationAnnotationmarkupType (highlight/underline/squiggly/strikeOut), x, y, width, height, color
stampAnnotationAnnotationicon, x, y, width, height, color
formXObjectTemplateref (library id), x, y, width, height
textFieldFormname, position, tooltip, defaultValue, multiline, password, maxLength, fontSize, readonly, required
checkboxFieldFormname, position, tooltip, checked, readonly, required
dropdownFieldFormname, position, tooltip, options (string[]), selectedIndex, fontSize, readonly, required
listBoxFieldFormname, position, tooltip, options (string[]), selectedIndex, fontSize, readonly, required
pushButtonFieldFormname, position, tooltip, label
signatureFieldFormname, position, tooltip
transformCompositeoperation (translate/scale/rotate/skew/matrix), params, content[]
clipCompositeshape (rectangle/circle/ellipse), shape params, content[]
layerCompositelayerRef, content[]
shadingGradientshadingId, x, y, width, height
tilingPatternPatternpatternId, x, y, width, height
alphaCompositestrokeAlpha (0–1), fillAlpha (0–1), content[]

Text Options Object

PropertyType / DefaultDescription
fontRefstringFont library id.
fontSizenumber / 12Size in points.
colorcolorFill color.
leadingnumberLine spacing in points. Default: fontSize Γ— 1.2.
renderingModestring / "fill""fill" Β· "stroke" Β· "fillAndStroke" Β· "invisible"
alignmentstring / "left""left" Β· "center" Β· "right" Β· "justify"
widthnumberMax width for wrapping/alignment.
decorationstring[]"underline" Β· "strikeOut" Β· "overline"
superscript / subscriptboolean / falseSuper/subscript rendering.
outlineColor / outlineWidthcolor / numberText stroke effect.
backgroundColorcolorHighlight behind text.
shadowColor / shadowOffsetX / shadowOffsetYcolor / numberDrop shadow.
rotationnumber / 0Degrees, counter-clockwise.

Draw Options Object

PropertyType / DefaultDescription
strokeColor / fillColorcolorStroke and fill colors.
lineWidthnumber / 1.0Stroke width in points.
lineCapstring / "butt""butt" Β· "round" Β· "projecting"
lineJoinstring / "miter""miter" Β· "round" Β· "bevel"
dashPatternnumber[]e.g. [5, 3] = 5pt dash, 3pt gap.
dashPhasenumber / 0Dash pattern phase offset.
strokeAlpha / fillAlphanumber / 1.0Opacity (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.

PdfXmlRenderer β€” Quick Start
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

MethodReturnsDescription
Render(string xml, string outputPath)voidRender an XML string to a PDF file.
Render(string xml, Stream outputStream)voidRender an XML string to a stream.
RenderFromFile(string xmlPath, string outputPath)voidLoad an .xml file and render it to a PDF file. Resolves relative paths from the XML file's directory.
BuildDocument(string xml)PdfDocumentParse XML and build a PdfDocument without saving.
BuildDocumentFromFile(string xmlPath)PdfDocumentLoad an .xml file and build a PdfDocument without saving.
RenderWithReport(string xml, string outputPath)PdfXmlRenderResultRender to file and return an accessibility report.
RenderWithReport(string xml, Stream outputStream)PdfXmlRenderResultRender to stream and return an accessibility report.

PdfXmlRenderer β€” Instance Methods

Create an instance with PdfXmlRendererOptions for configurable rendering.

MethodReturnsDescription
RenderToFile(string xml, string outputPath)voidRender using instance options to a file.
RenderToStream(string xml, Stream outputStream)voidRender using instance options to a stream.
RenderToFileWithReport(string xml, string outputPath)PdfXmlRenderResultRender to file with accessibility report.
RenderToStreamWithReport(string xml, Stream outputStream)PdfXmlRenderResultRender to stream with accessibility report.

PdfXmlRendererOptions

PropertyType / DefaultDescription
BasePathstring / CWDBase directory for resolving relative file paths in font, image, and attachment entries.
ImageFetchTimeoutSecondsint / 10Timeout in seconds for fetching URL-based images.
MaxRedirectsint / 3Maximum HTTP redirects for URL images.
AllowInsecureImageUrlsbool / falseSkip SSL certificate validation for URL images.
GenerateAccessibilityReportbool / falseGenerate an accessibility report after building the PDF.

PdfXmlRenderResult

PropertyTypeDescription
AccessibilityReportPdfAccessibilityReport?The accessibility report, or null if not enabled.

PdfXmlValidator

Validate an XML document without rendering it.

MethodReturnsDescription
Validate(string xml)PdfXmlValidationResultValidates the XML by deserializing and running all XV001–XV025 rules. Returns errors and warnings.

PdfXmlValidationResult

PropertyTypeDescription
IsValidbooltrue when there are no errors.
ErrorsIReadOnlyList<PdfXmlValidationItem>Validation errors (document cannot be rendered).
WarningsIReadOnlyList<PdfXmlValidationItem>Validation warnings (document can be rendered but may have issues).

PdfXmlRenderException

Thrown when XML-to-PDF rendering fails. Inherits from Exception.

PropertyTypeDescription
ValidationResultPdfXmlValidationResult?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.

Minimal XML Document
<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

MethodReturnsDescription
Render(string csv, string outputPath)voidRender a CSV string to a PDF file.
Render(string csv, Stream outputStream)voidRender a CSV string to a stream.
RenderFromFile(string csvPath, string outputPath)voidLoad a .csv file and render it to a PDF file. Resolves relative paths from the CSV file's directory.
BuildDocument(string csv)PdfDocumentParse CSV and build a PdfDocument without saving.
BuildDocumentFromFile(string csvPath)PdfDocumentLoad a .csv file and build a PdfDocument without saving.
CreateFormTemplate(string documentTitle = "New Form", int pageCount = 1)stringCreate a starter CSV template for form-based documents with sample document settings, fonts, and page sections.
RenderWithReport(string csv, string outputPath)PdfCsvRenderResultRender to file and return an accessibility report.
RenderWithReport(string csv, Stream outputStream)PdfCsvRenderResultRender to stream and return an accessibility report.

PdfCsvRenderer β€” Instance Methods

Create an instance with PdfCsvRendererOptions for configurable rendering.

MethodReturnsDescription
RenderToFile(string csv, string outputPath)voidRender using instance options to a file.
RenderToStream(string csv, Stream outputStream)voidRender using instance options to a stream.
RenderToFileWithReport(string csv, string outputPath)PdfCsvRenderResultRender to file with accessibility report.
RenderToStreamWithReport(string csv, Stream outputStream)PdfCsvRenderResultRender to stream with accessibility report.

PdfCsvRendererOptions

PropertyType / DefaultDescription
BasePathstring / CWDBase directory for resolving relative file paths in font, image, and attachment entries.
ImageFetchTimeoutSecondsint / 10Timeout in seconds for fetching URL-based images.
MaxRedirectsint / 3Maximum HTTP redirects for URL images.
AllowInsecureImageUrlsbool / falseSkip SSL certificate validation for URL images.
GenerateAccessibilityReportbool / falseGenerate an accessibility report after building the PDF.

PdfCsvRenderResult

PropertyTypeDescription
AccessibilityReportPdfAccessibilityReport?The accessibility report, or null if not enabled.

PdfCsvValidator

Validate a CSV document without rendering it.

MethodReturnsDescription
Validate(string csv)PdfCsvValidationResultValidates the CSV by deserializing and running all CV001–CV025 rules. Returns errors and warnings.

PdfCsvValidationResult

PropertyTypeDescription
IsValidbooltrue when there are no errors.
ErrorsIReadOnlyList<PdfCsvValidationItem>Validation errors (document cannot be rendered).
WarningsIReadOnlyList<PdfCsvValidationItem>Validation warnings (document can be rendered but may have issues).

PdfCsvRenderException

Thrown when CSV-to-PDF rendering fails. Inherits from Exception.

PropertyTypeDescription
ValidationResultPdfCsvValidationResult?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.

Minimal CSV Document
[PAGE 1]
type,x,y,text
text,72,720,Hello ObviousPDF!