class PdfHelper

Helper class to create PDF files with TCPDF lib

Constants

ORIENTATION_PORTRAIT

Constant for Portrait orientation

ORIENTATION_LANDSCAPE

Constant for Landscape orientation

Properties

protected TCPDF $_pdf TCPDF instance
protected string $_encoding Encoding set before creating the TCPDF ; used to restore the user encoding after processing

Methods

__construct(string $configfile, string $orientation, string $author, string $title, string $subject = '', int $fontsize = 10, string $fontname = 'helvetica')

Constructor

TCPDF
getPdf()

Get TCPDF instance

setHeader(string $logo, string $header1, string $header2)

Set header (logo and two lines)

setAutoPageBreak(bool $b)

Set auto page break automatic or not

addPage()

Create a new page (blank), must be followed by see PdfHelper::writeHTML

addHTMLPage(string $html)

Create a new page with html content

writeHTML(string $html)

Add html content to the current page

output(string $filename, string $dest = 'F')

Output PDF file

Details

at line 56
__construct(string $configfile, string $orientation, string $author, string $title, string $subject = '', int $fontsize = 10, string $fontname = 'helvetica')

Constructor

Parameters

string $configfile Path to an external TCPDF config file to use
string $orientation One of the orientation constant (see PdfHelper::ORIENTATION_PORTRAIT or PdfHelper::ORIENTATION_LANDSCAPE)
string $author Author of PDF document ; will appear in the PDF document properties
string $title Title of PDF document ; will appear in the PDF document properties
string $subject Subject of PDF document ; will appear in the PDF document properties
int $fontsize Default font-size
string $fontname Default font family

at line 98
TCPDF getPdf()

Get TCPDF instance

Return Value

TCPDF

at line 111
setHeader(string $logo, string $header1, string $header2)

Set header (logo and two lines)

Parameters

string $logo Path to a logo to display in the header margin
string $header1 First line of text to print in the header
string $header2 Second line of text to print in the header

at line 134
setAutoPageBreak(bool $b)

Set auto page break automatic or not

Parameters

bool $b True to enable auto page break, false otherwise (content may overflow)

at line 146
addPage()

Create a new page (blank), must be followed by see PdfHelper::writeHTML

at line 157
addHTMLPage(string $html)

Create a new page with html content

Parameters

string $html HTML content to add to the PHP document

at line 169
writeHTML(string $html)

Add html content to the current page

Parameters

string $html HTML content to add

at line 185
output(string $filename, string $dest = 'F')

Output PDF file

Parameters

string $filename Path to file to create
string $dest Export method : dest=F (file), I (inline), D (download)