PHP Класс mikehaertl\wkhtmlto\Image

This class is a slim wrapper around wkhtmltoimage.
Автор: Michael Härtl ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$binary the name of the wkhtmltoimage binary. Default is wkhtmltoimage. 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.
$type the image type. Default is 'png'. Other options are 'jpg' and 'bmp'.

Защищенные свойства (Protected)

Свойство Тип Описание
$_command the command instance that executes wkhtmltopdf
$_error the detailed error message. Empty string if none.
$_isCreated whether the PDF was created
$_options options for wkhtmltoimage as array('--opt1', '--opt2'=>'val', ...)
$_page the page input or a File instance for HTML string inputs
$_tmpImageFile the temporary image file

Открытые методы

Метод Описание
__construct ( array | string $options = null )
getCommand ( ) : Command
getError ( ) : string
getImageFilename ( ) : string
getMimeType ( ) : string
saveAs ( string $filename ) : boolean Save the image to given filename (triggers image creation)
send ( string | null $filename = null, boolean $inline = false ) : boolean Send image to client, either inline or as download (triggers image creation)
setOptions ( array $options = [] ) : static Set options
setPage ( string $page ) : static Add a page object to the output

Защищенные методы

Метод Описание
createImage ( ) : boolean Run the Command to create the tmp image file

Описание методов

__construct() публичный метод

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

createImage() защищенный метод

Run the Command to create the tmp image file
protected createImage ( ) : 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.

getImageFilename() публичный метод

public getImageFilename ( ) : string
Результат string the filename of the temporary image file

getMimeType() публичный метод

public getMimeType ( ) : string
Результат string the mime type for the current image

saveAs() публичный метод

Save the image to given filename (triggers image creation)
public saveAs ( string $filename ) : boolean
$filename string to save image as
Результат boolean whether image was created successfully

send() публичный метод

Send image to client, either inline or as download (triggers image 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. Note, that the file extension must match what you configured as $type (png, jpg, ...).
$inline boolean whether to force inline display of the image, even if filename is present.
Результат boolean whether image was created successfully

setOptions() публичный метод

Set options
public setOptions ( array $options = [] ) : static
$options array list of image options to set as name/value pairs
Результат static the Image instance for method chaining

setPage() публичный метод

Add a page object to the output
public setPage ( string $page ) : static
$page string either a URL, a HTML string or a filename
Результат static the Image instance for method chaining

Описание свойств

$_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

$_options защищенное свойство

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

$_page защищенное свойство

the page input or a File instance for HTML string inputs
protected $_page

$_tmpImageFile защищенное свойство

the temporary image file
protected $_tmpImageFile

$binary публичное свойство

the name of the wkhtmltoimage binary. Default is wkhtmltoimage. 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

$type публичное свойство

the image type. Default is 'png'. Other options are 'jpg' and 'bmp'.
public $type