PDF File class for generating PDFs from HTML.
This class can be used to generate PDFs from HTML sources. It extends the Hazaar\File class so all of it's methods are available. The difference here is that when calling Hazaar\File\PDF::set_content(), the content is filtered throught the PDF generator. So you can set the content as HTML and the actual stored content will be in PDF format.
If the content being set is already in PDF format, there is protection coded in that does not attempt to re-render the content.
Constants
PDF_PORTRAIT
const PDF_PORTRAIT = Portrait
PDF_LANDSCAPE
const PDF_LANDSCAPE = Landscape
Properties
sourceURL
public string $sourceURL
tmp
public Temp $tmp
status
private string $status
orient
private string $orient
size
private string $size
toc
private bool $toc
copies
private int $copies
grayscale
private bool $grayscale
title
private string $title
margins
private array $margins
lastError
private string $lastError
Methods
__construct
Hazaar\File\PDF constructor.
public __construct({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$file | string | Filename to use if the file will be written to disk. If null, the file can exist only in memory. |
$manager | Manager | An optional file manager for accessing public file data |
$relative_path | string | internal relative path when accessing the file through a Hazaar\File\Dir object |
setOrientation
Set orientation, use constants from this class.
public setOrientation({Array})
By default orientation is portrait.
Parameters
Parameter | Type | Description |
---|---|---|
$mode | string | use constants from this class |
setPageSize
Set page/paper size.
public setPageSize({Array})
By default page size is A4.
Parameters
Parameter | Type | Description |
---|---|---|
$size | string | Formal paper size (eg; A4, letter...) |
setTOC
Whether to automatically generate a TOC (table of contents) or not.
public setTOC({Array})
By default TOC is disabled.
Parameters
Parameter | Type | Description |
---|---|---|
$enabled | bool | true use TOC, false disable TOC |
setCopies
Set the number of copies to be printed.
public setCopies({Array})
By default it is one.
Parameters
Parameter | Type | Description |
---|---|---|
$count | int | number of page copies |
setGrayscale
Whether to print in grayscale or not.
public setGrayscale({Array})
By default it is OFF.
Parameters
Parameter | Type | Description |
---|---|---|
$mode | bool | true to print in grayscale, false in full color |
setTitle
Set PDF title. If empty, HTML <title> of first document is used.
public setTitle({Array})
By default it is empty.
Parameters
Parameter | Type | Description |
---|---|---|
$text | string |
setContents
Set the HTML content of the new PDF file.
public setContents({Array})
This content should be HTML format and will be converted into a PDF immediately and stored in memory. set_content() will not directly write the file to storage. If you want to do that, use put_content() instead.
Parameters
Parameter | Type | Description |
---|---|---|
$content | string | The HTML content to convert into a PDF |
setSource
Set source URL of content.
public setSource({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$url | string | A url accessible from the host that will be rendered to a PDF |
getStatus
Returns WKPDF print status.
public getStatus({Array})
install
public install({Array})
setMargin
public setMargin({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$top | string | |
$right | string | |
$bottom | string | |
$left | string |
mimeContentType
public mimeContentType({Array})
render
FILE_FILTER_SET Content filter to convert HTML to PDF.
protected render({Array})
This is the guts of it really. This is the method that converts the HTML content being set into a PDF.
Parameters
Parameter | Type | Description |
---|---|---|
$bytes | string |
getCommand
private getCommand({Array})
_pipeExec
private _pipeExec({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$cmd | string | |
$input | string |
Generated by Hazaar API Doc Generator