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

PropertyTypeDefaultDescription
Titlestring?nullDocument title displayed in the title bar and document properties. Required for PDF/UA-1.
Authorstring?nullName of the person or organization that created the document.
Subjectstring?nullBrief description of the document's content or purpose.
Keywordsstring?nullComma-separated keywords for searchability and categorization.
Creatorstring?nullThe application that created the original document content (e.g. your app's name).
Producerstring?"FolioPDF"The library that produced the PDF output. Defaults to "FolioPDF".
Languagestring?nullBCP 47 language tag (e.g. "en-US", "de-DE", "ja"). Required for PDF/UA-1.
CreationDateDateTimeOffsetDateTimeOffset.NowWhen the document was created. Defaults to the current time.
ModifiedDateDateTimeOffsetDateTimeOffset.NowWhen 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

PropertyTypeDefaultDescription
PdfAConformancePdfAConformanceNonePDF/A archival conformance level. See enum table below.
PdfUaConformancePdfUaConformanceNonePDF/UA accessibility conformance level. See enum table below.
ContentDirectionContentDirectionLeftToRightDefault text and layout direction for the entire document.
CompressDocumentbooltrueWhether to compress the output PDF streams. Disable for debugging.
ImageCompressionQualityImageCompressionQualityHighJPEG compression quality hint for opaque images embedded in the PDF.
ImageRasterDpiint288DPI for rasterizing images. 288 = 4× the 72pt base. Higher = sharper images but larger files.
AutoTagDocumentbooltrueAutomatically insert PDF structure tags on content elements. Set to false for full manual control.
EnableFormsboolfalseEnable interactive AcroForm widgets in the output. Requires a PDFium post-processing round-trip.

Enums Reference

PdfAConformance

ValueDescription
NoneStandard PDF (no archival conformance)
PdfA_2APDF/A-2a - full accessibility, PDF 1.7 features
PdfA_2BPDF/A-2b - basic visual fidelity, PDF 1.7 features
PdfA_2UPDF/A-2u - Unicode mapping for all glyphs
PdfA_3APDF/A-3a - full accessibility + arbitrary file attachments
PdfA_3BPDF/A-3b - basic visual fidelity + arbitrary file attachments
PdfA_3UPDF/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

ValueDescription
NoneNo enforced accessibility requirements
PdfUA_1PDF/UA-1 - ISO 14289-1 universal accessibility. Requires Title and Language in metadata.

ContentDirection

ValueDescription
LeftToRightLeft-to-right writing direction (Latin, Cyrillic, Greek, etc.)
RightToLeftRight-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

ValueDescription
BestHighest visual fidelity (largest file size)
HighHigh visual fidelity (default)
MediumBalanced quality and file size
LowLower fidelity, smaller file
VeryLowLowest 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

PropertyTypeDefaultDescription
EnableCachingbooltrueLayout calculation caching. Improves performance at the cost of slightly higher memory usage.
EnableDebuggingboolDebugger.IsAttachedDetailed layout overflow messages with exact space measurements. Enabled automatically when debugging.
CheckIfAllTextGlyphsAreAvailableboolDebugger.IsAttachedThrow an exception if a glyph is missing from the specified font. Catches font issues early.
UseEnvironmentFontsbooltrueWhether to use fonts installed in the OS. Set to false for reproducible output across environments.
FontDiscoveryPathsICollection<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:

SettingDefault Value
Titlenull (no title)
Authornull
Subjectnull
Keywordsnull
Creatornull
Producer"FolioPDF"
Languagenull
CreationDateDateTimeOffset.Now
ModifiedDateDateTimeOffset.Now
PdfAConformanceNone
PdfUaConformanceNone
ContentDirectionLeftToRight
CompressDocumenttrue
ImageCompressionQualityHigh
ImageRasterDpi288 (4 × 72)
AutoTagDocumenttrue
EnableFormsfalse
EnableCachingtrue
EnableDebuggingDebugger.IsAttached
CheckIfAllTextGlyphsAreAvailableDebugger.IsAttached
UseEnvironmentFontstrue
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");