Skip to main content

How to convert HTML to PDF in COM/ActiveX? Efficient conversion, Steps & ASP code. Over 22 Years in PDF Libraries.

HTML to PDF in COM/ActiveX

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()
MyDocument.DrawToWeb

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.