How to set pages in HTML Conversion

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Converter for .NET (v1)  /  How to set pages in HTML Conversion

DynamicPDF Converter for .NET (v1) Forum

 Dec 08 2015 11:58 AM
Hello,

I am using Dynamic PDF Converter to convert an html file containing a few tables to a pdf file. How do I set the dimensions of the pages and how do I make sure that page breaks occur at the right position?
Posted by a ceTe Software moderator
Hello,

You can set the page size using the HtmlconversionOptions class of DynamicPDF Converter API. You will need to create HtmlconversionOptions class object by specifying the desired dimensions for the page and apply this conversion options for conversions. You can refer to the documentation on conversion options here. Please note that it is not possible to add page breaks while converting the HTML file to PDF using DynamicPDF Converter API but if you have added the page breaks in the HTML file then it should work for you. Below is the code sample for setting page dimensions and converting HTML text having page breaks.

       string htmlText = "<style>.break { page-break-before: always; }</style><body>Sample content on page 1...<h1 class='break'>text of Heading 1 on page 2</h1>content on page 2...</body>";
       HtmlConversionOptions options = new HtmlConversionOptions(ceTe.DynamicPDF.Conversion.PageSize.Letter, ceTe.DynamicPDF.Conversion.PageOrientation.Portrait, 20);
       Converter.ConvertHtmlString(htmlText, @"C:\temp\Outputconverter.pdf",options);

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 2:24 AM.