\Hazaar\File
PDF
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.

Summary
Methods Properties Constants
Constants
PDF_LANDSCAPE
PDF_LANDSCAPE
PDF generated as landscape (horizontal).
PDF_PORTRAIT
PDF_PORTRAIT
PDF generated as landscape (vertical).
Properties
$copies
$copies
$grayscale
$grayscale
$last_error
$last_error
$margins
$margins
$orient
$orient
$size
$size
$source_url
$source_url
$status
$status
$title
$title
$tmp
$tmp
$toc
$toc
Methods
__construct()
__construct($file = null, $backend = null, $manager = null, $relative_path = null)
Hazaar\File\PDF constructor

Tags

Throws

Exception\WKPDFInstallFailed The automated installation of WKPDFtoHTML failed.

Throws

Exception\WKPDFNotExecutable The WKPDFtoHTML executable exists but failed to execute.

Parameters

$filemixed

Filename to use if the file will be written to disk. If null, the file can exist only in memory.

$backendmixed

The file backend to use for reading/writing the file.

$managermixed

An optional file manager for accessing public file data

$relative_pathmixed

Internal relative path when accessing the file through a Hazaar\File\Dir object.

Static
_pipeExec()
_pipeExec($cmd, $input = '') : array
Advanced execution routine.

Parameters

$cmdstring

The command to execute.

$inputstring

Any input not in arguments.

Returns

array

An array of execution data; stdout, stderr and return "error" code.

getCommand()
getCommand()
getStatus()
getStatus() : string
Returns WKPDF print status.

Returns

string

WPDF print status.

install()
install()
mime_content_type()
mime_content_type()
render()
render($bytes)
FILE_FILTER_SET Content filter to convert HTML to PDF.

This is the guts of it really. This is the method that converts the HTML content being set into a PDF.

Parameters

$bytes

No description

setCopies()
setCopies($count)
Set the number of copies to be printed.

By default it is one.

Parameters

$countinteger

Number of page copies.

setGrayscale()
setGrayscale($mode)
Whether to print in grayscale or not.

By default it is OFF.

Parameters

$mode

No description

setMargin()
setMargin($top, $right = null, $bottom = null, $left = null)

Parameters

$top

No description

$right

No description

$bottom

No description

$left

No description

setOrientation()
setOrientation($mode)
Set orientation, use constants from this class.

By default orientation is portrait.

Parameters

$modestring

Use constants from this class.

setPageSize()
setPageSize($size)
Set page/paper size.

By default page size is A4.

Parameters

$sizestring

Formal paper size (eg; A4, letter...)

setSource()
setSource($url)
Set source URL of content.

Parameters

$urlstring

A url accessible from the host that will be rendered to a PDF

setTOC()
setTOC($enabled)
Whether to automatically generate a TOC (table of contents) or not.

By default TOC is disabled.

Parameters

$enabledboolean

True use TOC, false disable TOC.

setTitle()
setTitle($text)
Set PDF title. If empty, HTML of first document is used.</div><div class="doc-page-detail"><p>By default it is empty.</p> </div><div class="doc-page-content"><h4>Parameters</h4><table class="table"><tr><td class="func-name">$text</td><td class="func-type"></td><td class="func-desc"><p><i class="small">No description</i></p> </td></tr></table></div><div class="api-tags"></div> <a name="func_set_contents"></a> <div class="doc-member-hdr"> <i class="fa fa-check-square-o"></i>set_contents()</div> <div class="doc-member-def">set_contents($content)</div><div class="doc-page-brief">Set the HTML content of the new PDF file.</div><div class="doc-page-detail"><p>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.</p> </div><div class="doc-page-content"><h4>Parameters</h4><table class="table"><tr><td class="func-name">$content</td><td class="func-type"><a href="http://php.net/manual/en/language.pseudo-types.php">mixed</a></td><td class="func-desc"><p>The HTML content to convert into a PDF</p> </td></tr></table></div></div> </div> </div> </main> <script> var doc = { project: 'hazaarmvc', version: '', path : '' } </script> <script type="text/javascript" src="http://scroly.io/hazaar/file/js/hazaar.js"></script> <script type="text/javascript">var hazaar = new HazaarJSHelper({"url":"http:\/\/scroly.io\/","data":null,"rewrite":true,"pathParam":"hz_path","queryParam":"hzqs"});</script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript" src="http://scroly.io/hazaar/file/js/jquery-helper.js"></script> <script type="text/javascript" src="http://scroly.io/script/doc/application.js"></script> </body> </html>