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:
Build the content tree on the
FlowDocument.Call
PaginateToPDFto get aPDFDoc.Set the metadata on that
PDFDocthroughGetDocInfo.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
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.
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?