Exponent v2.7.2

expWKPDF extends expHtmlToPDF
in package

This is the class expHtmlToPDF

Tags
author

Christian Sciberras

see

http://code.google.com/p/wkhtmltopdf/

copyright

2010 Christian Sciberras / Covac Software.

license

None. There are no restrictions on use, however keep copyright intact. Modification is allowed, keep track of modifications below in this comment block.

example

//-- Create sample PDF and embed in browser. --//

// Include WKPDF class.
require_once('wkhtmltopdf/wkhtmltopdf.php');
// Create PDF object.
$pdf=new WKPDF();
// Set PDF's HTML
$pdf->set_html('Hello <b>Mars</b>!');
// Convert HTML to PDF
$pdf->render();
// Output PDF. The file name is suggested to the browser.
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');

version
0.0

Chris - Created class.
0.1 Chris - Variable paths fixes.
0.2 Chris - Better error handlng (via exceptions).
IMPORTANT: Make sure that there is a folder in %LIBRARY_PATH%/tmp that is writable!

Features/Bugs/Contact
Found a bug? Want a modification? Contact me at uuf6429@gmail.com or contact@covac-software.com... guaranteed to get a reply within 2 hours at most (daytime GMT+1).

subpackage

Subsystems

Table of Contents

$pdf  : mixed
Private use variables.
$PDF_ASSTRING  : mixed
Returns the PDF file as a string.
$PDF_DOWNLOAD  : mixed
Force the client to download PDF file.
$PDF_EMBEDDED  : mixed
When possible, force the client to embed (display) PDF file.
$PDF_LANDSCAPE  : mixed
PDF generated as landscape (horizontal).
$PDF_PORTRAIT  : mixed
PDF generated as landscape (vertical).
$PDF_SAVEFILE  : mixed
PDF file is saved into the server space. The path is returned.
$orient  : mixed
$size  : mixed
$cmd  : mixed
$copies  : mixed
$cpu  : mixed
$grayscale  : mixed
$html  : mixed
Private use variables.
$status  : mixed
$title  : mixed
$tmp  : mixed
$toc  : mixed
__construct()  : mixed
Constructor: initialize command line and reserve temporary file.
__get()  : null
Generic magic method
__isset()  : bool
Generic magic method
__set()  : mixed
Generic magic method We MUST create/set non-existing properties for Exponent code to work
__unset()  : mixed
Generic magic method
createpdf()  : string|bool
Return PDF with various options.
get_help()  : string
Attempts to return the library's full help.
get_status()  : string
Returns WKPDF print status.
installed()  : mixed
Return status of pdf engine being installed correctly
render()  : mixed
Convert HTML to PDF.
set_copies()  : mixed
Set the number of copies to be printed.
set_html()  : mixed
Set html content.
set_html_file()  : mixed
Set html content by file.
set_orientation()  : mixed
Set orientation, use constants from this class.
set_page_size()  : mixed
Set page/paper size.
set_toc()  : mixed
Whether to automatically generate a TOC (table of contents) or not.
_getCPU()  : string
Function that attempts to return the kind of CPU.
_pipeExec()  : array<string|int, mixed>
Advanced execution routine.

Properties

$PDF_ASSTRING

Returns the PDF file as a string.

public static mixed $PDF_ASSTRING = 'S'

$PDF_DOWNLOAD

Force the client to download PDF file.

public static mixed $PDF_DOWNLOAD = 'D'

$PDF_EMBEDDED

When possible, force the client to embed (display) PDF file.

public static mixed $PDF_EMBEDDED = 'I'

$PDF_LANDSCAPE

PDF generated as landscape (horizontal).

public static mixed $PDF_LANDSCAPE = 'landscape'

$PDF_PORTRAIT

PDF generated as landscape (vertical).

public static mixed $PDF_PORTRAIT = 'portrait'

$PDF_SAVEFILE

PDF file is saved into the server space. The path is returned.

public static mixed $PDF_SAVEFILE = 'F'

Methods

__construct()

Constructor: initialize command line and reserve temporary file.

public __construct([string $paper_size = HTMLTOPDF_PAPER ][, string $orientation = "portrait" ][, null $html = null ][, bool $use_file = false ]) : mixed
Parameters
$paper_size : string = HTMLTOPDF_PAPER
$orientation : string = "portrait"
$html : null = null
$use_file : bool = false
Tags
throws
Exception
Return values
mixed

__get()

Generic magic method

public __get( $property) : null
Parameters
$property :
Return values
null

__isset()

Generic magic method

public __isset( $property) : bool
Parameters
$property :
Return values
bool

__set()

Generic magic method We MUST create/set non-existing properties for Exponent code to work

public __set( $property,  $value) : mixed
Parameters
$property :
$value :
Return values
mixed

__unset()

Generic magic method

public __unset( $property) : mixed
Parameters
$property :
Return values
mixed

createpdf()

Return PDF with various options.

public createpdf(string $mode, string $file) : string|bool
Parameters
$mode : string

How two output (constants from this same class).

$file : string

The PDF's filename (the usage depends on $mode.

Tags
throws
Exception
Return values
string|bool

Depending on $mode, this may be success (boolean) or PDF (string).

get_help()

Attempts to return the library's full help.

public get_help() : string
Return values
string

WKHTMLTOPDF HTML help.

get_status()

Returns WKPDF print status.

public get_status() : string
Return values
string

WPDF print status.

installed()

Return status of pdf engine being installed correctly

public static installed() : mixed
Return values
mixed

render()

Convert HTML to PDF.

public render() : mixed
Tags
throws
Exception
Return values
mixed

set_copies()

Set the number of copies to be printed.

public set_copies(int $count) : mixed

By default it is one.

Parameters
$count : int

Number of page copies.

Return values
mixed

set_html()

Set html content.

public set_html(string $html) : mixed
Parameters
$html : string

New html content. It replaces any previous content.

Return values
mixed

set_html_file()

Set html content by file.

public set_html_file(string $htmlfile) : mixed
Parameters
$htmlfile : string

the html file to use

Return values
mixed

set_orientation()

Set orientation, use constants from this class.

public set_orientation(string $mode) : mixed

By default orientation is portrait.

Parameters
$mode : string

Use constants from this class.

Return values
mixed

set_page_size()

Set page/paper size.

public set_page_size(string $size) : mixed
Parameters
$size : string

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

Return values
mixed

set_toc()

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

public set_toc(bool $enabled) : mixed

By default TOC is disabled.

Parameters
$enabled : bool

True use TOC, false disable TOC.

Return values
mixed

_getCPU()

Function that attempts to return the kind of CPU.

private static _getCPU() : string
Tags
throws
Exception
Return values
string

CPU kind ('amd64' or 'i386').

_pipeExec()

Advanced execution routine.

private static _pipeExec(string $cmd[, string $input = '' ]) : array<string|int, mixed>
Parameters
$cmd : string

The command to execute.

$input : string = ''

Any input not in arguments.

Return values
array<string|int, mixed>

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

Search results