For the complete documentation index, see llms.txt. This page is also available as Markdown.

PDF Metadata

Document metadata - title, author, subject, keywords - is not part of the content tree. It belongs to the PDF that PaginateToPDF produces, so it is set through the regular PDFDoc API rather than through FlowDocument.

Where metadata fits

The content tree describes what the document says; metadata describes what the document is. The order is therefore always the same:

  1. Build the content tree on the FlowDocument.

  2. Call PaginateToPDF to get a PDFDoc.

  3. Set the metadata on that PDFDoc through GetDocInfo.

  4. Save.

Because metadata is applied to the paginated result, none of it affects layout, and setting it costs nothing extra; PaginateToPDF has already done the expensive work by that point.

Set the document info

PDFDoc.GetDocInfo returns a PDFDocInfo whose setters map onto the standard PDF document information entries.

using (PDFDoc pdf = doc.PaginateToPDF())
{
    PDFDocInfo info = pdf.GetDocInfo();
    info.SetTitle("Quarterly Revenue Report 2025");
    info.SetAuthor("SYH Supply Co.");
    info.SetSubject("Revenue by region, Q1-Q3");
    info.SetKeywords("revenue, quarterly, report");
    info.SetCreator("Reporting Service 4.2");

    Date created = new Date();
    created.SetCurrentTime();
    info.SetCreationDate(created);

    pdf.Save(output_path + "report.pdf", SDFDoc.SaveOptions.e_linearized);
}
PDFDoc pdf = doc.PaginateToPDF();

PDFDocInfo info = pdf.GetDocInfo();
info.SetTitle("Quarterly Revenue Report 2025");
info.SetAuthor("SYH Supply Co.");
info.SetSubject("Revenue by region, Q1-Q3");
info.SetKeywords("revenue, quarterly, report");
info.SetCreator("Reporting Service 4.2");

Date created;
created.SetCurrentTime();
info.SetCreationDate(created);

pdf.Save(output_path + "report.pdf", SDF::SDFDoc::e_linearized, 0);

Available entries

Entry
Meaning

SetTitle

The document's title.

SetAuthor

The person or organization that created the content.

SetSubject

What the document is about.

SetKeywords

Comma separated keywords, used by search and indexing tools.

SetCreator

The application that produced the original content. This is typically your own application name.

SetProducer

The application that produced the PDF.

SetCreationDate

When the document was created.

SetModDate

When the document was last modified.

Each setter has a matching getter (GetTitle, GetAuthor and so on), so the metadata of a generated document can be read back or copied from another document.

Info

Producer is filled in by the SDK, and ModDate is maintained automatically on save. Set them explicitly only if you need to override that behavior.

Dates

SetCreationDate and SetModDate take a Date. SetCurrentTime fills it from the system clock, which covers most generation scenarios. To record a specific timestamp instead, like the reporting period rather than the moment of generation, construct the Date with explicit year, month, day, hour, minute and second components.

Further Reading

Sections, headers and footers for visible page-level information such as titles and page numbers.

Last updated

Was this helpful?