Click or drag to resize
Pdf Library for .NET
Pdf Document Properties

As described in Document Properties page, Select.Pdf Library for .NET can be used to set pdf document properties, such as:

  • Title

  • Author

  • Subject

  • Keywords

  • Creation Date

This can be done using DocumentInformation property of the PdfDocument object.

What's interesting when it comes to the Html to Pdf Converter, is that Select.Pdf Library can take advantage of the web page properties it converts and set the document properties title, subject and keywords with the corresponding web page properties (title, description, keywords).

To access the web page properties, after the conversion, the HtmlToPdf object exposes a property called ConversionResult. This is an instance of HtmlToPdfResult class and contains details about conversion, including details about the original web page in WebPageInformation property.

Sample Code

This sample code shows how to convert a web page to pdf using Select.Pdf and set the basic pdf document information (title, subject, keywords) with the values taken from the webpage.

// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();

// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl(TxtUrl.Text);

// get conversion result (contains document info from the web page)
HtmlToPdfResult result = converter.ConversionResult;

// set the document properties
doc.DocumentInformation.Title = result.WebPageInformation.Title;
doc.DocumentInformation.Subject = result.WebPageInformation.Description;
doc.DocumentInformation.Keywords = result.WebPageInformation.Keywords;

doc.DocumentInformation.Author = "Select.Pdf Samples";
doc.DocumentInformation.CreationDate = DateTime.Now;

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
See Also