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
- Create a
HtmlLayout
object. - Load the page using hte URL and specify the page height and width.
- Create a
Header
andFooter
as required to theHtmlLayout
object. - Convert the URI to Document by calling
Layout
method. - 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.
- .NET - DynamicPDF Generator for .NET
- Java - DynamicPDF Generator for Java