#include <HTML2PDF.h>
Public Types | |
typedef pdftron::PDF::Proxy | Proxy |
typedef pdftron::PDF::WebPageSettings | WebPageSettings |
typedef pdftron::PDF::TOCSettings | TOCSettings |
Public Member Functions | |
void | InsertFromURL (const UString &url) |
void | InsertFromURL (const UString &url, const WebPageSettings &settings) |
void | InsertFromHtmlString (const UString &html) |
void | InsertFromHtmlString (const UString &html, const WebPageSettings &settings) |
void | InsertTOC () |
void | InsertTOC (const TOCSettings &settings) |
bool | Convert (PDFDoc &doc) |
int | GetHTTPErrorCode () const |
void | SetQuiet (bool quiet) |
void | SetCompatibilityMode (bool compatibility) |
void | SetLogFilePath (const UString &path) |
UString | GetLog () const |
HTML2PDF () | |
~HTML2PDF () | |
void | SetPaperSize (PrinterMode::PaperSize size) |
void | SetPaperSize (const UString &width, const UString &height) |
void | SetLandscape (bool enable) |
void | SetDPI (int dpi) |
void | SetOutline (bool enable, int depth=4) |
void | DumpOutline (const UString &xml_file) |
void | SetPDFCompression (bool enable) |
void | SetMargins (const UString &top, const UString &bottom, const UString &left, const UString &right) |
void | SetHeader (const UString &header) |
void | SetFooter (const UString &footer) |
void | SetImageDPI (int dpi) |
void | SetImageQuality (int quality) |
void | SetCookieJar (const UString &path) |
void | AddCookie (const UString &name, const UString &value) |
void | SetCustomHeader (const UString &name, const UString &value) |
void | Destroy () |
Static Public Member Functions | |
static bool | Convert (PDFDoc &doc, const UString &url) |
static bool | Convert (PDFDoc &doc, const UString &url, const WebPageSettings &settings) |
static void | SetModulePath (const UString &path) |
static bool | IsModuleAvailable () |
'pdftron.PDF.HTML2PDF' is an optional PDFNet Add-On utility class that can be used to convert HTML web pages into PDF documents by using an external module (html2pdf).
The html2pdf modules can be downloaded from http: www.pdftron.com/pdfnet/downloads.html.
Users can convert HTML pages to PDF using the following operations:
The following code converts a single webpage to pdf
The following code demonstrates how to convert multiple web pages into one pdf, excluding the background, and with lowered image quality to save space.
Definition at line 64 of file HTML2PDF.h.
Definition at line 67 of file HTML2PDF.h.
Definition at line 69 of file HTML2PDF.h.
Definition at line 68 of file HTML2PDF.h.
pdftron::PDF::HTML2PDF::HTML2PDF | ( | ) |
Default constructor.
pdftron::PDF::HTML2PDF::~HTML2PDF | ( | ) |
Destructor.
Add cookie to the HTTP Headers when converting via a URL.
name | - the name of the cookie. |
value | - the value of the cookie. |
Convert the HTML document at url and append the results to doc.
doc | - Target PDF to which converted HTML pages will be appended to. |
url | - HTML page, or relative path to local HTML page, that will be converted to PDF format. |
|
static |
Convert the HTML document at url and append the results to doc.
doc | - Target PDF to which converted HTML pages will be appended to. |
url | - HTML page, or relative path to local HTML page, that will be converted to PDF format. |
settings | - Modify how the web page is loaded and converted. |
bool pdftron::PDF::HTML2PDF::Convert | ( | PDFDoc & | doc | ) |
Convert HTML documents and append the results to doc.
doc | - Target PDF to which converted HTML pages will be appended to. |
void pdftron::PDF::HTML2PDF::Destroy | ( | ) |
Frees the native memory of the object.
void pdftron::PDF::HTML2PDF::DumpOutline | ( | const UString & | xml_file | ) |
int pdftron::PDF::HTML2PDF::GetHTTPErrorCode | ( | ) | const |
Return the largest HTTP error code encountered during conversion
UString pdftron::PDF::HTML2PDF::GetLog | ( | ) | const |
Get results of conversion, including errors and warnings, in human readable form.
void pdftron::PDF::HTML2PDF::InsertFromHtmlString | ( | const UString & | html | ) |
Convert HTML encoded in string.
html | - String containing HTML code. |
void pdftron::PDF::HTML2PDF::InsertFromHtmlString | ( | const UString & | html, |
const WebPageSettings & | settings | ||
) |
Convert HTML encoded in string.
html | - String containing HTML code. |
settings | - How the HTML content described in html is loaded. |
void pdftron::PDF::HTML2PDF::InsertFromURL | ( | const UString & | url | ) |
Add a web page to be converted. A single URL typically results in many PDF pages.
url | - HTML page, or relative path to local HTML page |
void pdftron::PDF::HTML2PDF::InsertFromURL | ( | const UString & | url, |
const WebPageSettings & | settings | ||
) |
Add a web page to be converted. A single URL typically results in many PDF pages.
url | - HTML page, or relative path to local HTML page |
settings | - How the web page should be loaded and converted |
void pdftron::PDF::HTML2PDF::InsertTOC | ( | ) |
void pdftron::PDF::HTML2PDF::InsertTOC | ( | const TOCSettings & | settings | ) |
|
static |
Find out whether the HTLML2PDF module is available (and licensed).
void pdftron::PDF::HTML2PDF::SetCompatibilityMode | ( | bool | compatibility | ) |
Provides the ability to run HTML to PDF conversion to run in compatibility mode, which runs with altered graphics options and does not create a dedicated render process. This option may be somewhat slower than the default mode. However, it may be required on environments with limited platform dependencies, such as AWS Lambda.
compatibility | - If true, compatibility mode is enabled. |
void pdftron::PDF::HTML2PDF::SetCookieJar | ( | const UString & | path | ) |
Path of file used for loading and storing cookies.
path | - Path to file used for loading and storing cookies. |
Add a custom HTTP header specified by name and value.
name | - the name of the custom header. |
value | - the value of the custom header. |
void pdftron::PDF::HTML2PDF::SetDPI | ( | int | dpi | ) |
Change the DPI explicitly for the output PDF.
dpi | - Dots per inch, e.g. 80. |
void pdftron::PDF::HTML2PDF::SetFooter | ( | const UString & | footer | ) |
Set footer of generated PDF.
footer | HTML string to be used as the footer |
void pdftron::PDF::HTML2PDF::SetHeader | ( | const UString & | header | ) |
Set header of generated PDF.
header | HTML string to be used as the header |
void pdftron::PDF::HTML2PDF::SetImageDPI | ( | int | dpi | ) |
void pdftron::PDF::HTML2PDF::SetImageQuality | ( | int | quality | ) |
void pdftron::PDF::HTML2PDF::SetLandscape | ( | bool | enable | ) |
void pdftron::PDF::HTML2PDF::SetLogFilePath | ( | const UString & | path | ) |
Sets the location of the log file to be used during conversion.
path | Full path and filename of file to log to. |
void pdftron::PDF::HTML2PDF::SetMargins | ( | const UString & | top, |
const UString & | bottom, | ||
const UString & | left, | ||
const UString & | right | ||
) |
Set margins of generated PDF.
top | - Size of the top margin, e.g. "2cm". |
bottom | - Size of the bottom margin, e.g. "2cm". |
left | - Size of the left margin, e.g. "2cm". |
right | - Size of the right margin, e.g. "2cm". |
|
static |
void pdftron::PDF::HTML2PDF::SetOutline | ( | bool | enable, |
int | depth = 4 |
||
) |
void pdftron::PDF::HTML2PDF::SetPaperSize | ( | PrinterMode::PaperSize | size | ) |
Manually set the paper dimensions of the produced PDF.
width | - Width of the page, e.g. "4cm". |
height | - Height of the page, eg. "12in". |
void pdftron::PDF::HTML2PDF::SetPDFCompression | ( | bool | enable | ) |
void pdftron::PDF::HTML2PDF::SetQuiet | ( | bool | quiet | ) |
Display HTML to PDF conversion progress, warnings, and errors, to stdout.
quiet | - If false, progress information is sent to stdout during conversion. |