\CGHTML2PDFhtml2pdf

This class provides a convenient mechanism for generating PDF from HTML content.

This class will read the modules preferences for page size, orientation, and headers and footers. Though the parameters allow overriding them.

This class directly uses mPdf for generating PDF from HTML. The HTML provided must be compatible with that understood by mPdf. Please see the documentation on that website for more information about supported and unsupportd HTML and CSS.

Trivial Example:
$obj = new \CGHTML2PDF\html2pdf();
$obj->writeHTML('<p>This is a test</p>');
$obj->Output();

Summary

Methods
Properties
Constants
__construct()
writeHTML()
Output()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(array $parms)

Constructor.

Parameters

array $parms

An array of parameters to override the preferences.
The parms associative array can have the following values:
string 'orientation' The page orientation. portrait, or landscape.
string 'pagesize' The page slze. Accepted values are letter,legal,A4,A5, etc.
int 'margin_left' Left margin (in milimiters).
int 'margin_top' Top margin (in milimiters). This value must account for the height of any page header.
int 'margin_bottom' Bottom margin (in milimiters). This value must account for the height of any page footer.
int 'margin_right' Right margin (in milimiters).

writeHTML()

writeHTML(string $html)

Generate the PDF code from the HTML.

This method does not generate a PDF file, however it builds the in-memory structure so that PDF can be generated. This can be a very memory intensive operation depending upon the size of the document provided.

Parameters

string $html

The HTML document.

Output()

Output(string $filename, string $dest)

Generate PDF output.

Parameters

string $filename

The destination filename.

string $dest

The output destination. Possible values are:
D: Send the file to the browser and force a file download with the name provided.
F: Save the PDF file to a local file with the name provided.
I: Send the file inline to the browser (default)
S: Return the document as a string. The filename is ignored.