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
MethodsPropertiesConstants
Constants
PDF_LANDSCAPE
PDF_LANDSCAPE : type
PDF generated as landscape (horizontal).

Type

\type - desc
PDF_PORTRAIT
PDF_PORTRAIT : type
PDF generated as landscape (vertical).

Type

\type - desc
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
Static
_pipeExec()
_pipeExec($cmd, $input = '') : array
Advanced execution routine.
getCommand()
getCommand()
getStatus()
getStatus() : string
Returns WKPDF 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.

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

By default it is one.

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

By default it is OFF.

setMargin()
setMargin($top, $right = null, $bottom = null, $left = null)
setOrientation()
setOrientation($mode)
Set orientation, use constants from this class.

By default orientation is portrait.

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

By default page size is A4.

setSource()
setSource($url)
Set source URL of content.
setTOC()
setTOC($enabled)
Whether to automatically generate a TOC (table of contents) or not.

By default TOC is disabled.

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="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> </div> </div> <div class="col col-sm-2 sidebar"> <div class="nav-title">Contents</div> <div class="nav nav-content"> <ul class="nav" id="nav-toc"></ul> </div> </div> </div> </div> <div class="bg-dark text-muted p-2" style="position: fixed; right: 0; bottom: 0; left: 0;"> Powered by <a href="http://scroly.io">Scroly.io</a> <small class="float-right">Generated: Thursday, October 3rd 2019 at 2:45pm</small> </div> </main> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.js"></script> <script type="text/javascript" src="https://scroly.io/themes/material/js/nav.js"></script> <script type="text/javascript" src="https://scroly.io/themes/material/js/doc.js"></script> </body> </html>