How to Convert HTML to PDF

The HtmlLayout class can be used to convert HTML to PDF using Generator with several custom options for page info, header and footer for the output PDF.

Steps for Creating a PDF Document

  1. Create a HtmlLayout object.
  2. Load the page using hte URL and specify the page height and width.
  3. Create a Header and Footer as required to the HtmlLayout object.
  4. Convert the URI to Document by calling Layout method.
  5. Output the Document to the Browser.

Sample code - ASP

Dim MyHtmlLayout
Set MyHtmlLayout = Server.CreateObject( "DynamicPDF.HtmlLayout" )
MyHtmlLayout.LoadHtmlUri "http://www.google.com", 595, 842

Dim MyHeaderHtmlLayoutElement
Set MyHeaderHtmlLayoutElement = MyHtmlLayout.AddCenterHeaderHTMLLayoutElement()
MyHeaderHtmlLayoutElement.Text = "%%PR%%%%SP%% of %%ST%%"
MyHeaderHtmlLayoutElement.HasPageNumbers = True
MyHeaderHtmlLayoutElement.Width = 200

Dim MyFooterHtmlLayoutElement
Set MyFooterHtmlLayoutElement = MyHtmlLayout.AddCenterFooterHTMLLayoutElement()
MyFooterHtmlLayoutElement.Text = "%%PR%%%%SP%% of %%ST%%"
MyFooterHtmlLayoutElement.HasPageNumbers = True
MyFooterHtmlLayoutElement.Width = 200

Dim MyDocument
Set MyDocument = MyHtmlLayout.Layout()

Getting Started

DynamicPDF Generator Information

More information can be found here:

Available in other platforms

DynamicPDF Generator is available for the following platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!