expWKPDF

Extends \expHtmlToPDF

author

Christian Sciberras

see

href="http://code.google.com/p/wkhtmltopdf/">http://code.google.com/p/wkhtmltopdf/">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

color="#008800">//-- 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).

package

Subsystems

Methods

Constructor: initialize a pdf file using selected engine.

__construct(string $paper_size = HTMLTOPDF_PAPER, string $orientation = "portrait", string $html = null, boolean $use_file = false) 
inherited

Arguments

$paper_size

string

page size

$orientation

string

page orientation

$html

string

html code for page

$use_file

boolean

a flag to show $html is an html file location to be loaded

Function that attempts to return the kind of CPU.

_getCPU() : string
static
Throws
\Exception

Response

string

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

Advanced execution routine.

_pipeExec(string $cmd, string $input = '') : array
static

Arguments

$cmd

string

The command to execute.

$input

string

Any input not in arguments.

Response

array

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

Render and Return PDF using various options.

createpdf(string $mode, string $file) : string|boolean
inherited

Arguments

$mode

string

How to output (constants from this same class).

$file

string

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

Response

string|boolean

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

Attempts to return the library's full help.

get_help() : string

Response

string

WKHTMLTOPDF HTML help.

Returns WKPDF print status.

get_status() : string

Response

string

WPDF print status.

Return status of pdf engine being installed correctly

installed() 
inherited static

Convert HTML to PDF.

render() 
inherited

Set the number of copies to be printed.

set_copies(integer $count) 

By default it is one.

Arguments

$count

integer

Number of page copies.

Set html content.

set_html(string $html) 
inherited

Arguments

$html

string

New html content. It replaces any previous content.

Set html content by file.

set_html_file(string $htmlfile) 
inherited

Arguments

$htmlfile

string

the html file to use

Set orientation, use constants from this class.

set_orientation(string $orientation) 
inherited

By default orientation is portrait.

Arguments

$orientation

string

orientation of paper

Set page/paper size.

set_page_size(string $size) 
inherited

Arguments

$size

string

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

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

set_toc(boolean $enabled) 

By default TOC is disabled.

Arguments

$enabled

boolean

True use TOC, false disable TOC.

Properties

Private use variables.

html : 

Type(s)

cmd

cmd : 

Type(s)

tmp

tmp : 

Type(s)

status

status : 

Type(s)

toc

toc : 

Type(s)

copies

copies : 

Type(s)

grayscale

grayscale : 

Type(s)

title

title : 

Type(s)

cpu

cpu : 
static

Type(s)

Private use variables.

pdf : 
inherited

Type(s)

size

size : 
inherited

Type(s)

orient

orient : 
inherited

Type(s)

Force the client to download PDF file.

PDF_DOWNLOAD : 
inherited static

Type(s)

Returns the PDF file as a string.

PDF_ASSTRING : 
inherited static

Type(s)

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

PDF_EMBEDDED : 
inherited static

Type(s)

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

PDF_SAVEFILE : 
inherited static

Type(s)

PDF generated as landscape (vertical).

PDF_PORTRAIT : 
inherited static

Type(s)

PDF generated as landscape (horizontal).

PDF_LANDSCAPE : 
inherited static

Type(s)