Configuration
Configure document metadata, generation settings, content direction, compression, PDF/A and PDF/UA conformance, and global library settings.
Document Metadata
Every PDF carries metadata fields visible in the document properties dialog (Acrobat: File → Properties). Set them via WithMetadata() on the document:
using FolioPDF;
using FolioPDF.Fluent;
using FolioPDF.Helpers;
using FolioPDF.Infrastructure;
Document.Create(doc =>
{
doc.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(50);
page.Content().Text("Configured document").FontSize(16);
});
})
.WithMetadata(new DocumentMetadata
{
Title = "Q1 Financial Report",
Author = "Finance Team",
Subject = "Quarterly revenue and expense summary",
Keywords = "finance, Q1, 2026, revenue",
Creator = "Acme Reporting System",
Producer = "FolioPDF",
Language = "en-US",
CreationDate = new DateTimeOffset(2026, 4, 1, 0, 0, 0, TimeSpan.Zero),
ModifiedDate = DateTimeOffset.Now
})
.GeneratePdf("configured.pdf");
DocumentMetadata Properties
| Property | Type | Default | Description |
|---|---|---|---|
Title |
string? |
null |
Document title displayed in the title bar and document properties. Required for PDF/UA-1. |
Author |
string? |
null |
Name of the person or organization that created the document. |
Subject |
string? |
null |
Brief description of the document's content or purpose. |
Keywords |
string? |
null |
Comma-separated keywords for searchability and categorization. |
Creator |
string? |
null |
The application that created the original document content (e.g. your app's name). |
Producer |
string? |
"FolioPDF" |
The library that produced the PDF output. Defaults to "FolioPDF". |
Language |
string? |
null |
BCP 47 language tag (e.g. "en-US", "de-DE", "ja"). Required for PDF/UA-1. |
CreationDate |
DateTimeOffset |
DateTimeOffset.Now |
When the document was created. Defaults to the current time. |
ModifiedDate |
DateTimeOffset |
DateTimeOffset.Now |
When the document was last modified. Defaults to the current time. |
Document Settings
Control the generation process — compliance levels, compression, image quality, form fields, and automatic structure tagging:
Document.Create(doc =>
{
doc.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(50);
page.Content().Text("High-quality archival document").FontSize(16);
});
})
.WithSettings(new DocumentSettings
{
PdfAConformance = PdfAConformance.PdfA_2B,
PdfUaConformance = PdfUaConformance.PdfUA_1,
ContentDirection = ContentDirection.LeftToRight,
CompressDocument = true,
ImageCompressionQuality = ImageCompressionQuality.High,
ImageRasterDpi = 288,
AutoTagDocument = true,
EnableForms = false
})
.WithMetadata(new DocumentMetadata
{
Title = "Archival Document",
Language = "en-US"
})
.GeneratePdf("archival.pdf");
DocumentSettings Properties
| Property | Type | Default | Description |
|---|---|---|---|
PdfAConformance |
PdfAConformance |
None |
PDF/A archival conformance level. See enum table below. |
PdfUaConformance |
PdfUaConformance |
None |
PDF/UA accessibility conformance level. See enum table below. |
ContentDirection |
ContentDirection |
LeftToRight |
Default text and layout direction for the entire document. |
CompressDocument |
bool |
true |
Whether to compress the output PDF streams. Disable for debugging. |
ImageCompressionQuality |
ImageCompressionQuality |
High |
JPEG compression quality hint for opaque images embedded in the PDF. |
ImageRasterDpi |
int |
288 |
DPI for rasterizing images. 288 = 4× the 72pt base. Higher = sharper images but larger files. |
AutoTagDocument |
bool |
true |
Automatically insert PDF structure tags on content elements. Set to false for full manual control. |
EnableForms |
bool |
false |
Enable interactive AcroForm widgets in the output. Requires a PDFium post-processing round-trip. |
Enums Reference
PdfAConformance
| Value | Description |
|---|---|
None | Standard PDF (no archival conformance) |
PdfA_2A | PDF/A-2a — full accessibility, PDF 1.7 features |
PdfA_2B | PDF/A-2b — basic visual fidelity, PDF 1.7 features |
PdfA_2U | PDF/A-2u — Unicode mapping for all glyphs |
PdfA_3A | PDF/A-3a — full accessibility + arbitrary file attachments |
PdfA_3B | PDF/A-3b — basic visual fidelity + arbitrary file attachments |
PdfA_3U | PDF/A-3u — Unicode mapping + arbitrary file attachments |
Which PDF/A level? Use PdfA_2B for general archiving. Use PdfA_3B if you need to embed attachments (e.g. ZUGFeRD/Factur-X invoices). The "a" variants add accessibility requirements (all content must be tagged) — combine with PdfUaConformance.PdfUA_1 for maximum compliance.
PdfUaConformance
| Value | Description |
|---|---|
None | No enforced accessibility requirements |
PdfUA_1 | PDF/UA-1 — ISO 14289-1 universal accessibility. Requires Title and Language in metadata. |
ContentDirection
| Value | Description |
|---|---|
LeftToRight | Left-to-right writing direction (Latin, Cyrillic, Greek, etc.) |
RightToLeft | Right-to-left writing direction (Arabic, Hebrew, etc.) |
// Arabic document
Document.Create(doc =>
{
doc.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(50);
page.ContentFromRightToLeft();
page.Content().Text("\u0645\u0631\u062D\u0628\u0627 \u0628\u0627\u0644\u0639\u0627\u0644\u0645").FontSize(24);
});
})
.WithSettings(new DocumentSettings
{
ContentDirection = ContentDirection.RightToLeft
})
.WithMetadata(new DocumentMetadata { Language = "ar" })
.GeneratePdf("arabic.pdf");
ImageCompressionQuality
| Value | Description |
|---|---|
Best | Highest visual fidelity (largest file size) |
High | High visual fidelity (default) |
Medium | Balanced quality and file size |
Low | Lower fidelity, smaller file |
VeryLow | Lowest fidelity, smallest file |
Global Settings
The Settings static class controls library-wide behaviour. These settings are applied before any document is generated.
using FolioPDF;
// Add a custom font directory
Settings.FontDiscoveryPaths.Add("/usr/share/fonts/custom");
Settings.FontDiscoveryPaths.Add("C:\\Fonts\\Corporate");
// Disable system fonts (use only explicitly registered fonts)
Settings.UseEnvironmentFonts = false;
// Enable caching for better performance (default: true)
Settings.EnableCaching = true;
// Enable debugging for detailed layout error messages
Settings.EnableDebugging = true;
// Throw on missing glyphs instead of rendering placeholders
Settings.CheckIfAllTextGlyphsAreAvailable = true;
Settings Properties
| Property | Type | Default | Description |
|---|---|---|---|
EnableCaching |
bool |
true |
Layout calculation caching. Improves performance at the cost of slightly higher memory usage. |
EnableDebugging |
bool |
Debugger.IsAttached |
Detailed layout overflow messages with exact space measurements. Enabled automatically when debugging. |
CheckIfAllTextGlyphsAreAvailable |
bool |
Debugger.IsAttached |
Throw an exception if a glyph is missing from the specified font. Catches font issues early. |
UseEnvironmentFonts |
bool |
true |
Whether to use fonts installed in the OS. Set to false for reproducible output across environments. |
FontDiscoveryPaths |
ICollection<string> |
{ AppDomain.CurrentDomain.BaseDirectory } |
Directories searched for font files. The application directory is included by default. |
Font discovery in containers. Docker images often lack system fonts. Either set UseEnvironmentFonts = false and bundle fonts alongside your app (they will be found via FontDiscoveryPaths), or install font packages in your Dockerfile (e.g. apt-get install fonts-liberation).
Default Values Summary
A quick reference of all default values when no explicit configuration is provided:
| Setting | Default Value |
|---|---|
| Title | null (no title) |
| Author | null |
| Subject | null |
| Keywords | null |
| Creator | null |
| Producer | "FolioPDF" |
| Language | null |
| CreationDate | DateTimeOffset.Now |
| ModifiedDate | DateTimeOffset.Now |
| PdfAConformance | None |
| PdfUaConformance | None |
| ContentDirection | LeftToRight |
| CompressDocument | true |
| ImageCompressionQuality | High |
| ImageRasterDpi | 288 (4 × 72) |
| AutoTagDocument | true |
| EnableForms | false |
| EnableCaching | true |
| EnableDebugging | Debugger.IsAttached |
| CheckIfAllTextGlyphsAreAvailable | Debugger.IsAttached |
| UseEnvironmentFonts | true |
| FontDiscoveryPaths | { AppDomain.CurrentDomain.BaseDirectory } |
Combining Metadata and Settings
WithMetadata() and WithSettings() can be chained in any order. Both return the Document instance for fluent chaining:
Document.Create(doc =>
{
doc.Page(page =>
{
page.Size(PageSizes.A4);
page.Margin(50);
page.Content().Text("Fully configured").FontSize(16);
});
})
.WithMetadata(new DocumentMetadata
{
Title = "Annual Report",
Author = "Legal Dept",
Language = "en-US"
})
.WithSettings(new DocumentSettings
{
PdfAConformance = PdfAConformance.PdfA_2A,
PdfUaConformance = PdfUaConformance.PdfUA_1,
ImageCompressionQuality = ImageCompressionQuality.Best,
ImageRasterDpi = 300
})
.GeneratePdf("annual-report.pdf");