WARNING:
The implementation of the ImportFromUrl method is currently "
a work in progress."
Use at your own risk!
Your feedback and bug reports would be appreciated.
Opens an HTTP URL and converts the content of the page into PDF.
Populates the current PdfDocument object with the result of the conversion.
The current PdfDocument can either be an empty document created with CreateDocument, or an existing
document opened via OpenDocument/OpenDocumentBinary.
Return value: if the Debug parameter (see below) is set to True, this method returns a log
of non-fatal errors. Otherwise returns an empty string.
URL can be an http or https address, such as "http://www.server.com/path/file.asp",
or a physical local path such as "c:\path\file.html".
For more information about this method, see Chapter 13 - HTML to PDF Conversion.
Param is a PdfParam object or parameter string specifying various conversion parameters
(all of them optional), including:
- PageWidth - page width, 612 (8.5") by default.
- PageHeight - page height, 792 (11") by default.
- LeftMargin, RightMargin, TopMargin, BottomMargin -
page margins, 54 (0.75") by default.
- Landscape - if set to True, the document's pages have landscape orientation.
False (portrait orientation) by default.
- CodePage - specifies the encoding of the page, similar to the View/Encoding option in a browser.
This parameter, if specified, overrides the charset value
specified via a <META http-equiv="Content-Type"> tag in the document's body.
1252 (US ASCII) by default.
- StopAfter - specifies the number of pages in a resultant document after which
the document creation will be aborted and an exception thrown. Used mostly for debugging purposes.
50 by default.
- DrawBackground - if set to True, each page of the generated PDF document
will display a background specified by the source HTML document's BGCOLOR or BACKGROUND
attributes (or their CSS equivalents BACKGROUND-COLOR and BACKGROUND-IMAGE.) False by default, which means the background
remains transparent/white regardless of the source HTML document's background settings.
- StartPage - specifies the 1-based index of a page to begin rendering on. Applies
to non-empty documents only. 1 by default.
- Debug - if set to True, the method returns a log of non-fatal errors
encountered during the HTML to PDF conversion process,
such as invalid image URLs, unknown fonts, etc. False by default.
This parameter should be used for debugging purposes only.
Username, Password specify authentication parameters in case the URL
is protected with basic authentication. These arguments can also be used to pass
the authentication cookie name (prefixed with the word "Cookie:") and cookie value
when using .NET Forms authentication. This is described in detail in
Section 13.2 - Authentication.
Usage:
Set Doc = Pdf.CreateDocument
Doc.ImportFromUrl "http://www.server.com/path/file.asp", "landscape=true"
Doc.Save "c:\path\doc.pdf"
Set Doc = Pdf.CreateDocument
LogString = Pdf.ImportFromUrl( "c:\path\doc.htm", "debug=true" )
Doc.Save "c:\path\doc.pdf"
Set Doc = Pdf.OpenDocument( "c:\path\template.pdf" )
Doc.ImportFromUrl "http://www.server.com/path/file.asp", "startpage=2"
Doc.Save "c:\path\doc.pdf"