Property | Type | Description | |
---|---|---|---|
$binary | the name of the wkhtmltopdf binary. Default is wkhtmltopdf. You can also configure a full path here. | ||
$commandOptions | options to pass to the Command constructor. Default is none. | ||
$ignoreWarnings | whether to ignore any errors if some PDF file was still created. Default is false. | ||
$tmpDir | the directory to use for temporary files. If null (default) the dir is autodetected. | ||
$version9 | whether the old version 9 of wkhtmltopdf is used (slightly different syntax). Default is false. |
Property | Type | Description | |
---|---|---|---|
$_command | the command instance that executes wkhtmltopdf | ||
$_error | the detailed error message. Empty string if none. | ||
$_isCreated | whether the PDF was created | ||
$_objects | list of wkhtmltopdf objects as arrays | ||
$_options | global options for wkhtmltopdf as array('--opt1', '--opt2'=>'val', ...) | ||
$_tmpFiles | list of tmp file objects. This is here to keep a reference to File and thus avoid too early call of File::__destruct() if the file is not referenced anymore. | ||
$_tmpPdfFile | the temporary PDF file |
Method | Description | |
---|---|---|
__construct ( array | string $options = null ) | ||
addCover ( string $input, array $options = [], string | null $type = null ) : static | Add a cover page object to the output | |
addPage ( string $input, array $options = [], string | null $type = null ) : static | Add a page object to the output | |
addToc ( array $options = [] ) : static | Add a TOC object to the output | |
getCommand ( ) : |
||
getError ( ) : string | ||
getPdfFilename ( ) : string | ||
saveAs ( string $filename ) : boolean | Save the PDF to given filename (triggers PDF creation) | |
send ( string | null $filename = null, boolean $inline = false ) : boolean | Send PDF to client, either inline or as download (triggers PDF creation) | |
setOptions ( array $options = [] ) : static | Set global option(s) | |
toString ( ) : string | boolean | Get the raw PDF contents (triggers PDF creation). |
Method | Description | |
---|---|---|
createPdf ( ) : boolean | Run the Command to create the tmp PDF file | |
processInput ( string $input, string | null $type = null ) : mikehaertl\tmp\File | string | ||
processOptions ( array $options = [] ) : array |
public __construct ( array | string $options = null ) | ||
$options | array | string | global options for wkhtmltopdf, a page URL, a HTML string or a filename |
public addCover ( string $input, array $options = [], string | null $type = null ) : static | ||
$input | string | either a URL, a HTML string or a filename |
$options | array | optional options for the cover page |
$type | string | null | a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content. |
return | static | the Pdf instance for method chaining |
public addPage ( string $input, array $options = [], string | null $type = null ) : static | ||
$input | string | either a URL, a HTML string or a filename |
$options | array | optional options for this page |
$type | string | null | a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content. |
return | static | the Pdf instance for method chaining |
public getCommand ( ) : |
||
return | the command instance that executes wkhtmltopdf |
public getPdfFilename ( ) : string | ||
return | string | the filename of the temporary PDF file |
protected processInput ( string $input, string | null $type = null ) : mikehaertl\tmp\File | string | ||
$input | string | |
$type | string | null | a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content. |
return | mikehaertl\tmp\File | string | a File object if the input is a HTML or XML string. The unchanged input otherwhise. |
protected processOptions ( array $options = [] ) : array | ||
$options | array | list of options as name/value pairs |
return | array | options with raw content converted to tmp files where neccessary |
public send ( string | null $filename = null, boolean $inline = false ) : boolean | ||
$filename | string | null | the filename to send. If empty, the PDF is streamed inline. |
$inline | boolean | whether to force inline display of the PDF, even if filename is present. |
return | boolean | whether PDF was created successfully |
public setOptions ( array $options = [] ) : static | ||
$options | array | list of global PDF options to set as name/value pairs |
return | static | the Pdf instance for method chaining |
protected $_options |
protected $_tmpFiles |
public $binary |
public $commandOptions |
public $ignoreWarnings |
public $tmpDir |