PHP 클래스 mikehaertl\wkhtmlto\Pdf

This class is a slim wrapper around wkhtmltopdf.
저자: Michael Härtl ([email protected])
파일 보기 프로젝트 열기: mikehaertl/phpwkhtmltopdf 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$binary the name of the wkhtmltopdf binary. Default is wkhtmltopdf. You can also configure a full path here.
$commandOptions options to pass to the Command constructor. Default is none.
$ignoreWarnings whether to ignore any errors if some PDF file was still created. Default is false.
$tmpDir the directory to use for temporary files. If null (default) the dir is autodetected.
$version9 whether the old version 9 of wkhtmltopdf is used (slightly different syntax). Default is false.

보호된 프로퍼티들

프로퍼티 타입 설명
$_command the command instance that executes wkhtmltopdf
$_error the detailed error message. Empty string if none.
$_isCreated whether the PDF was created
$_objects list of wkhtmltopdf objects as arrays
$_options global options for wkhtmltopdf as array('--opt1', '--opt2'=>'val', ...)
$_tmpFiles list of tmp file objects. This is here to keep a reference to File and thus avoid too early call of File::__destruct() if the file is not referenced anymore.
$_tmpPdfFile the temporary PDF file

공개 메소드들

메소드 설명
__construct ( array | string $options = null )
addCover ( string $input, array $options = [], string | null $type = null ) : static Add a cover page object to the output
addPage ( string $input, array $options = [], string | null $type = null ) : static Add a page object to the output
addToc ( array $options = [] ) : static Add a TOC object to the output
getCommand ( ) : Command
getError ( ) : string
getPdfFilename ( ) : string
saveAs ( string $filename ) : boolean Save the PDF to given filename (triggers PDF creation)
send ( string | null $filename = null, boolean $inline = false ) : boolean Send PDF to client, either inline or as download (triggers PDF creation)
setOptions ( array $options = [] ) : static Set global option(s)
toString ( ) : string | boolean Get the raw PDF contents (triggers PDF creation).

보호된 메소드들

메소드 설명
createPdf ( ) : boolean Run the Command to create the tmp PDF file
processInput ( string $input, string | null $type = null ) : mikehaertl\tmp\File | string
processOptions ( array $options = [] ) : array

메소드 상세

__construct() 공개 메소드

public __construct ( array | string $options = null )
$options array | string global options for wkhtmltopdf, a page URL, a HTML string or a filename

addCover() 공개 메소드

Add a cover page object to the output
public addCover ( string $input, array $options = [], string | null $type = null ) : static
$input string either a URL, a HTML string or a filename
$options array optional options for the cover page
$type string | null a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content.
리턴 static the Pdf instance for method chaining

addPage() 공개 메소드

Add a page object to the output
public addPage ( string $input, array $options = [], string | null $type = null ) : static
$input string either a URL, a HTML string or a filename
$options array optional options for this page
$type string | null a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content.
리턴 static the Pdf instance for method chaining

addToc() 공개 메소드

Add a TOC object to the output
public addToc ( array $options = [] ) : static
$options array optional options for the table of contents
리턴 static the Pdf instance for method chaining

createPdf() 보호된 메소드

Run the Command to create the tmp PDF file
protected createPdf ( ) : boolean
리턴 boolean whether creation was successful

getCommand() 공개 메소드

public getCommand ( ) : Command
리턴 Command the command instance that executes wkhtmltopdf

getError() 공개 메소드

public getError ( ) : string
리턴 string the detailed error message. Empty string if none.

getPdfFilename() 공개 메소드

public getPdfFilename ( ) : string
리턴 string the filename of the temporary PDF file

processInput() 보호된 메소드

protected processInput ( string $input, string | null $type = null ) : mikehaertl\tmp\File | string
$input string
$type string | null a type hint if the input is a string of known type. This can either be `TYPE_HTML` or `TYPE_XML`. If `null` (default) the type is auto detected from the string content.
리턴 mikehaertl\tmp\File | string a File object if the input is a HTML or XML string. The unchanged input otherwhise.

processOptions() 보호된 메소드

protected processOptions ( array $options = [] ) : array
$options array list of options as name/value pairs
리턴 array options with raw content converted to tmp files where neccessary

saveAs() 공개 메소드

Save the PDF to given filename (triggers PDF creation)
public saveAs ( string $filename ) : boolean
$filename string to save PDF as
리턴 boolean whether PDF was created successfully

send() 공개 메소드

Send PDF to client, either inline or as download (triggers PDF creation)
public send ( string | null $filename = null, boolean $inline = false ) : boolean
$filename string | null the filename to send. If empty, the PDF is streamed inline.
$inline boolean whether to force inline display of the PDF, even if filename is present.
리턴 boolean whether PDF was created successfully

setOptions() 공개 메소드

Set global option(s)
public setOptions ( array $options = [] ) : static
$options array list of global PDF options to set as name/value pairs
리턴 static the Pdf instance for method chaining

toString() 공개 메소드

Get the raw PDF contents (triggers PDF creation).
public toString ( ) : string | boolean
리턴 string | boolean The PDF content as a string or `false` if the PDF wasn't created successfully.

프로퍼티 상세

$_command 보호되어 있는 프로퍼티

the command instance that executes wkhtmltopdf
protected $_command

$_error 보호되어 있는 프로퍼티

the detailed error message. Empty string if none.
protected $_error

$_isCreated 보호되어 있는 프로퍼티

whether the PDF was created
protected $_isCreated

$_objects 보호되어 있는 프로퍼티

list of wkhtmltopdf objects as arrays
protected $_objects

$_options 보호되어 있는 프로퍼티

global options for wkhtmltopdf as array('--opt1', '--opt2'=>'val', ...)
protected $_options

$_tmpFiles 보호되어 있는 프로퍼티

list of tmp file objects. This is here to keep a reference to File and thus avoid too early call of File::__destruct() if the file is not referenced anymore.
protected $_tmpFiles

$_tmpPdfFile 보호되어 있는 프로퍼티

the temporary PDF file
protected $_tmpPdfFile

$binary 공개적으로 프로퍼티

the name of the wkhtmltopdf binary. Default is wkhtmltopdf. You can also configure a full path here.
public $binary

$commandOptions 공개적으로 프로퍼티

options to pass to the Command constructor. Default is none.
public $commandOptions

$ignoreWarnings 공개적으로 프로퍼티

whether to ignore any errors if some PDF file was still created. Default is false.
public $ignoreWarnings

$tmpDir 공개적으로 프로퍼티

the directory to use for temporary files. If null (default) the dir is autodetected.
public $tmpDir

$version9 공개적으로 프로퍼티

whether the old version 9 of wkhtmltopdf is used (slightly different syntax). Default is false.
public $version9