PHP Class CakePdf\Pdf\CakePdf

Mostra file Open project: ceeram/cakepdf Class Usage Examples

Protected Properties

Property Type Description
$_allow mixed false: none true: all array: List of permissions that are allowed
$_availablePermissions array Available permissions
$_cache string | boolean Cache config name, if set to false cache is disabled
$_cryptoClass CakePdf\Pdf\Crypto\AbstractPdfCrypto Instance of PdfCrypto class
$_delay integer Javascript delay before rendering document in milliseconds
$_encoding string Encoding
$_engineClass CakePdf\Pdf\Engine\AbstractPdfEngine Instance of PdfEngine class
$_footer string Footer HTML
$_header string Header HTML
$_helpers array Helpers to be used in the render
$_html string Html to be rendered
$_layout string Layout for the View
$_layoutPath string Path to the layout - defaults to 'pdf'
$_marginBottom number Bottom margin in mm
$_marginLeft number Left margin in mm
$_marginRight number Right margin in mm
$_marginTop number Top margin in mm
$_orientation string Orientation of the pdf
$_ownerPassword boolean Owner password, used with crypto
$_pageSize string Page size of the pdf
$_protect boolean Flag that tells if we need to pass it through crypto
$_template string Template for the view
$_templatePath string Path to the template - defaults to 'Pdf'
$_theme array Theme for the View
$_title string Title of the document
$_userPassword boolean User password, used with crypto
$_viewRender string View for render
$_viewVars array Vars to sent to render
$_windowStatus string Window status required before rendering document

Public Methods

Method Description
__construct ( array $config = [] ) Constructor
cache ( null | boolean | string $cache = null ) : mixed Get/Set caching.
crypto ( string $name = null ) : AbstractPdfCrypto Load PdfCrypto
delay ( null | integer $delay = null ) : mixed Get/Set javascript delay.
encoding ( null | string $encoding = null ) : mixed Get/Set Encoding.
engine ( string $name = null ) : CakePdf\Pdf\Engine\AbstractPdfEngine Load PdfEngine
footer ( null | string $left = null, null | string $center = null, null | string $right = null ) : mixed Get/Set footer HTML.
header ( null | string $left = null, null | string $center = null, null | string $right = null ) : mixed Get/Set header HTML.
helpers ( array $helpers = null ) : mixed Helpers to be used in render
html ( null | string $html = null ) : mixed Get/Set Html.
layoutPath ( mixed $layoutPath = false ) : mixed Layout path
margin ( null | string | array $bottom = null, null | string $left = null, null | string $right = null, null | string $top = null ) : mixed Get/Set page margins.
marginBottom ( null | string $margin = null ) : mixed Get/Set bottom margin.
marginLeft ( null | string $margin = null ) : mixed Get/Set left margin.
marginRight ( null | string $margin = null ) : mixed Get/Set right margin.
marginTop ( null | string $margin = null ) : mixed Get/Set top margin.
orientation ( null | string $orientation = null ) : mixed Get/Set Orientation.
output ( null | string $html = null ) : string Create pdf content from html. Can be used to write to file or with PdfView to display
ownerPassword ( null | string $password = null ) : mixed Get/Set ownerPassword.
pageSize ( null | string $pageSize = null ) : mixed Get/Set Page size.
permissions ( null | boolean | array $permissions = null ) : mixed Get/Set permissions.
protect ( null | boolean $protect = null ) : mixed Get/Set protection.
template ( mixed $template = false, mixed $layout = null ) : mixed Template and layout
templatePath ( mixed $templatePath = false ) : mixed Template path
theme ( string $theme = null ) : mixed Theme to use when rendering
title ( null | string $title = null ) : mixed Get/Set document title.
userPassword ( null | string $password = null ) : mixed Get/Set userPassword
viewRender ( string $viewClass = null ) : mixed View class for render
viewVars ( array $viewVars = null ) : mixed Variables to be set on render
windowStatus ( null | string $status = null ) : mixed Get/Set the required window status for rendering Waits until the status is equal to the string before rendering the pdf
write ( string $destination, boolean $create = true, string $html = null ) : boolean Writes output to file

Protected Methods

Method Description
_render ( ) : array Build and set all the view properties needed to render the layout and template.

Method Details

__construct() public method

Constructor
public __construct ( array $config = [] )
$config array Pdf configs to use

_render() protected method

Build and set all the view properties needed to render the layout and template.
protected _render ( ) : array
return array The rendered template wrapped in layout.

cache() public method

Get/Set caching.
public cache ( null | boolean | string $cache = null ) : mixed
$cache null | boolean | string Cache config name to use, If true is passed, 'cake_pdf' will be used.
return mixed

crypto() public method

Load PdfCrypto
public crypto ( string $name = null ) : AbstractPdfCrypto
$name string Classname of crypto engine without `Crypto` suffix. For example `CakePdf.Pdftk`
return CakePdf\Pdf\Crypto\AbstractPdfCrypto

delay() public method

Get/Set javascript delay.
public delay ( null | integer $delay = null ) : mixed
$delay null | integer delay to set in milliseconds
return mixed

encoding() public method

Get/Set Encoding.
public encoding ( null | string $encoding = null ) : mixed
$encoding null | string encoding to set
return mixed

engine() public method

Load PdfEngine
public engine ( string $name = null ) : CakePdf\Pdf\Engine\AbstractPdfEngine
$name string Classname of pdf engine without `Engine` suffix. For example `CakePdf.DomPdf`
return CakePdf\Pdf\Engine\AbstractPdfEngine

header() public method

Get/Set header HTML.
public header ( null | string $left = null, null | string $center = null, null | string $right = null ) : mixed
$left null | string left side header
$center null | string center header
$right null | string right side header
return mixed

helpers() public method

Helpers to be used in render
public helpers ( array $helpers = null ) : mixed
$helpers array helpers to use
return mixed

html() public method

Get/Set Html.
public html ( null | string $html = null ) : mixed
$html null | string Html to set
return mixed

layoutPath() public method

Layout path
public layoutPath ( mixed $layoutPath = false ) : mixed
$layoutPath mixed The path of the layout file to use
return mixed

margin() public method

Several options are available Array format ------------ First param can be an array with the following options: - bottom - left - right - top Set margin for all borders -------------------------- $bottom is set to a string Leave all other parameters empty Set margin for horizontal and vertical -------------------------------------- $bottom value will be set to bottom and top $left value will be set to left and right
public margin ( null | string | array $bottom = null, null | string $left = null, null | string $right = null, null | string $top = null ) : mixed
$bottom null | string | array bottom margin, or array of margins
$left null | string left margin
$right null | string right margin
$top null | string top margin
return mixed

marginBottom() public method

Get/Set bottom margin.
public marginBottom ( null | string $margin = null ) : mixed
$margin null | string margin to set
return mixed

marginLeft() public method

Get/Set left margin.
public marginLeft ( null | string $margin = null ) : mixed
$margin null | string margin to set
return mixed

marginRight() public method

Get/Set right margin.
public marginRight ( null | string $margin = null ) : mixed
$margin null | string margin to set
return mixed

marginTop() public method

Get/Set top margin.
public marginTop ( null | string $margin = null ) : mixed
$margin null | string margin to set
return mixed

orientation() public method

Get/Set Orientation.
public orientation ( null | string $orientation = null ) : mixed
$orientation null | string orientation to set
return mixed

output() public method

Create pdf content from html. Can be used to write to file or with PdfView to display
public output ( null | string $html = null ) : string
$html null | string Html content to render. If omitted, the template will be rendered with viewVars and layout that have been set.
return string

ownerPassword() public method

The owner password is used to control who can modify, print, manage the PDF document.
public ownerPassword ( null | string $password = null ) : mixed
$password null | string password to set
return mixed

pageSize() public method

Get/Set Page size.
public pageSize ( null | string $pageSize = null ) : mixed
$pageSize null | string Page size to set
return mixed

permissions() public method

all: allow all permissions none: allow no permissions array: list of permissions that are allowed
public permissions ( null | boolean | array $permissions = null ) : mixed
$permissions null | boolean | array Permissions to set
return mixed

protect() public method

Get/Set protection.
public protect ( null | boolean $protect = null ) : mixed
$protect null | boolean True or false
return mixed

template() public method

Template and layout
public template ( mixed $template = false, mixed $layout = null ) : mixed
$template mixed Template name or null to not use
$layout mixed Layout name or null to not use
return mixed

templatePath() public method

Template path
public templatePath ( mixed $templatePath = false ) : mixed
$templatePath mixed The path of the template to use
return mixed

theme() public method

Theme to use when rendering
public theme ( string $theme = null ) : mixed
$theme string theme to use
return mixed

title() public method

Get/Set document title.
public title ( null | string $title = null ) : mixed
$title null | string title to set
return mixed

userPassword() public method

The user password is used to control who can open the PDF document.
public userPassword ( null | string $password = null ) : mixed
$password null | string password to set
return mixed

viewRender() public method

View class for render
public viewRender ( string $viewClass = null ) : mixed
$viewClass string name of the view class to use
return mixed

viewVars() public method

Variables to be set on render
public viewVars ( array $viewVars = null ) : mixed
$viewVars array view variables to set
return mixed

windowStatus() public method

Get/Set the required window status for rendering Waits until the status is equal to the string before rendering the pdf
public windowStatus ( null | string $status = null ) : mixed
$status null | string status to set as string
return mixed

write() public method

Writes output to file
public write ( string $destination, boolean $create = true, string $html = null ) : boolean
$destination string Absolute file path to write to
$create boolean Create file if it does not exist (if true)
$html string Html to write
return boolean

Property Details

$_allow protected_oe property

false: none true: all array: List of permissions that are allowed
protected mixed $_allow
return mixed

$_availablePermissions protected_oe property

Available permissions
protected array $_availablePermissions
return array

$_cache protected_oe property

Cache config name, if set to false cache is disabled
protected string|bool $_cache
return string | boolean

$_cryptoClass protected_oe property

Instance of PdfCrypto class
protected AbstractPdfCrypto,CakePdf\Pdf\Crypto $_cryptoClass
return CakePdf\Pdf\Crypto\AbstractPdfCrypto

$_delay protected_oe property

Javascript delay before rendering document in milliseconds
protected int $_delay
return integer

$_encoding protected_oe property

Encoding
protected string $_encoding
return string

$_engineClass protected_oe property

Instance of PdfEngine class
protected AbstractPdfEngine,CakePdf\Pdf\Engine $_engineClass
return CakePdf\Pdf\Engine\AbstractPdfEngine

$_header protected_oe property

Header HTML
protected string $_header
return string

$_helpers protected_oe property

Helpers to be used in the render
protected array $_helpers
return array

$_html protected_oe property

Html to be rendered
protected string $_html
return string

$_layout protected_oe property

Layout for the View
protected string $_layout
return string

$_layoutPath protected_oe property

Path to the layout - defaults to 'pdf'
protected string $_layoutPath
return string

$_marginBottom protected_oe property

Bottom margin in mm
protected number $_marginBottom
return number

$_marginLeft protected_oe property

Left margin in mm
protected number $_marginLeft
return number

$_marginRight protected_oe property

Right margin in mm
protected number $_marginRight
return number

$_marginTop protected_oe property

Top margin in mm
protected number $_marginTop
return number

$_orientation protected_oe property

Orientation of the pdf
protected string $_orientation
return string

$_ownerPassword protected_oe property

Owner password, used with crypto
protected bool $_ownerPassword
return boolean

$_pageSize protected_oe property

Page size of the pdf
protected string $_pageSize
return string

$_protect protected_oe property

Flag that tells if we need to pass it through crypto
protected bool $_protect
return boolean

$_template protected_oe property

Template for the view
protected string $_template
return string

$_templatePath protected_oe property

Path to the template - defaults to 'Pdf'
protected string $_templatePath
return string

$_theme protected_oe property

Theme for the View
protected array $_theme
return array

$_title protected_oe property

Title of the document
protected string $_title
return string

$_userPassword protected_oe property

User password, used with crypto
protected bool $_userPassword
return boolean

$_viewRender protected_oe property

View for render
protected string $_viewRender
return string

$_viewVars protected_oe property

Vars to sent to render
protected array $_viewVars
return array

$_windowStatus protected_oe property

Window status required before rendering document
protected string $_windowStatus
return string