Skip to main content

ConversionOptions

Version: 1.0

Formatting Using ConversionOptions

DynamicPDF HTML Converter supports formatting PDF output using the ConversionOptions class. Features include adding PDF metadata and formatting the PDF document. For more details, refer to the ConversionOptions API documentation. The following example illustrates some formatting you can apply to a document.

string outputDocumentPath = "./tale-two-cities--document.pdf";
string taleOfTwoCities = "https://www.gutenberg.org/files/98/98-h/98-h.htm";
Uri resolvePath = new Uri(taleOfTwoCities);
double leftRightMarginsPts = 36;
double topBottomMarginsPts = 144;

ConversionOptions conversionOptions = new ConversionOptions(PageSize.Letter,
PageOrientation.Portrait, leftRightMarginsPts, topBottomMarginsPts);
conversionOptions.Author = "Charles Dickens";
conversionOptions.Creator = "James B";
conversionOptions.Title = "A Tale of Two Cities";
conversionOptions.Subject = "Guttenberg press version of Charles Dickens\'s"
+ "A Tale of Two Cities.";
conversionOptions.Header = "<div style = 'text-align:center;width:100%"
+ ";font-size:15em;'>A Tale of Two Cities</div>";
Converter.Convert(resolvePath, outputDocumentPath, conversionOptions);
Dim outputDocumentPath As String = "./tale-two-cities--document.pdf"
Dim taleOfTwoCities As String = "https://www.gutenberg.org/files/98/98-h/98-h.htm"
Dim resolvePath As Uri = New Uri(taleOfTwoCities)
Dim leftRightMarginsPts As Double = 36
Dim topBottomMarginsPts As Double = 144

Dim conversionOptions As ConversionOptions = New ConversionOptions(PageSize.Letter,
PageOrientation.Portrait, leftRightMarginsPts, topBottomMarginsPts)
conversionOptions.Author = "Charles Dickens"
conversionOptions.Creator = "James B"
conversionOptions.Title = "A Tale of Two Cities"
conversionOptions.Subject = "Guttenberg press version of Charles Dickens\'s" &
"A Tale of Two Cities."
conversionOptions.Header = "<div style = 'text-align:center;width:100%" &
";font-size:15em;'>A Tale of Two Cities</div>"
Converter.Convert(resolvePath, outputDocumentPath, conversionOptions)

Properties​

ConversionOptions supports the following properties.

Properties
AuthorGets or sets the Author for metadata in converted PDF.
BottomMarginGets or sets the bottom margin of the page in points.
CreatorGets or sets the Creator for metadata in converted PDF.
FooterGets or sets Footer
HeaderGets or sets Header
HeightGets or sets the width of the page in points.
IncludeBackgroundGets or sets the include back ground in bool.
KeywordsGets or sets the Keywords for metadata in converted PDF.
LeftMarginGets or sets the left margin of the page in points.
OverrideCssPageSizeGets or sets the override css page size in bool.
ProducerGets or sets the Producer for metadata in converted PDF.
RightMarginGets or sets the right margin of the page in points.
SubjectGets or sets the Subject for metadata in converted PDF.
TitleGets or sets the Title for metadata in converted PDF.
TopMarginGets or sets the top margin of the page in points.
WidthGets or sets the width of the page in points.
ZoomDetermines the magnification level for the HTML. [0.1 to 2.0]

GitHub​

An example demonstrating conversion options when using DynamicPDF HTML Converter is available on GitHub.

The relevant C# file is:

  • WithConversionOptions.cs

and the VB .NET file is:

  • WithConversionOptions.vb