class PDF extends Renderer

Constants

DEFAULT_CREATOR

DEFAULT_MARGIN

UNIT_PX

UNIT_IN

UNIT_CM

UNIT_MM

FORMAT_A0

FORMAT_A1

FORMAT_A2

FORMAT_A3

FORMAT_A4

FORMAT_A5

FORMAT_A6

FORMAT_LETTER

FORMAT_LEGAL

FORMAT_TABLOID

FORMAT_LEDGER

Properties

protected string $format
protected string $extension from  Renderer
protected array $options from  Renderer
protected array $tags

Methods

__construct(string $url, array $options = [])

No description

ResponseInterface
fetch()

No description

from  Renderer
setOption(string $key, mixed $value)

Set option

from  Renderer
getOption(string $key, $default = null)

No description

from  Renderer
devicePixelRatio(float $pixelRatio = 1.0)

Sets the devicePixelRatio of the viewport

from  Renderer
waitUntilLoaded()

Waits until the entire document, including resources are fully loaded.

from  Renderer
waitUntiDOMContentLoaded()

Waits until the 'DOMContentLoaded' event is fired.

from  Renderer
waitUntiNetworkIdle()

Waits until there has not been any network requests for at least 500ms

from  Renderer
waitUntiNetworkSettled()

Waits until there has not been more than 2 network requests for at least 500ms

from  Renderer
timeout(int $timeout)

Maximum amount of time to wait before timing out in milliseconds. Defaults to 30000

from  Renderer
resource
stream()

Get the rendered content as a file handle (resource)

from  Renderer
string|null
blob()

Get the rendered content as a blob

from  Renderer
Response
download(string $filename = null)

Retrieve the rendered content as a download response

from  Renderer
Response
toResponse(Request $request = null)

Retrieve the rendered content as a response

from  Renderer
string
link()

Retrieve URL to the rendered content

from  Renderer
ResponseInterface
postProcess(ResponseInterface $response)

Postprocessing stage

static Renderer
url(string $url)

Render from url external or interal

from  Renderer
static Renderer
from(HtmlString|string $html)

Render from raw markup

from  Renderer
static Renderer
view(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Render from a view

from  Renderer
static Renderer
route(array|string $name = null, mixed $parameters = [], bool $absolute = true)

Render from named route.

from  Renderer
array
__debugInfo()

No description

from  Renderer
string
__toString()

No description

from  Renderer
string
jsonSerialize()

No description

from  Renderer
string
toJson(int $options = 0)

No description

from  Renderer
string
getVersion()

Gets the application version string

PDF
displayHeaderFooter(bool $displayHeaderFooter = true)

Enable the display of header and footer

PDF
headerTemplateFrom(HtmlString|string $template)

Sets the HTML template for the print header.

PDF
headerTemplate(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Sets the HTML template for the print header from a blade view

PDF
footerTemplateFrom(HtmlString|string $template)

Sets the HTML template for the print footer.

PDF
footerTemplate(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Sets the HTML template for the print footer from a blade view

PDF
pageRanges(array|int ...$ranges)

Paper ranges to print, e.g., [1, 5], 8, [11, 13]

PDF
printBackground(bool $printBackground = true)

Print background graphics. Defaults to false

PDF
marginTop(int|string $marginTop, string $unit = PDF::UNIT_CM)

Paper top margin

PDF
marginRight(int|string $marginRight, string $unit = PDF::UNIT_CM)

Paper right margin

PDF
marginBottom(int|string $marginBottom, string $unit = PDF::UNIT_CM)

Paper bottom margin

PDF
marginLeft(int|string $marginLeft, string $unit = PDF::UNIT_CM)

Paper left margin

PDF
margin(int|string ...$values)

Paper margins

PDF
format(string $format = PDF::FORMAT_A4)

Paper format. If set, takes priority over width or height options. Defaults to 'A4'

static int|string
appendUnit(int|string $value, string|null $unit = null)

Appends the given unit to value if the unit is valid

PDF
emulatedMedia(string|null $media = null)

Sets the media emulation. Defaults to NULL

PDF
width(int $width)

Paper width

PDF
height(int $height)

Paper height

PDF
preferCSSPageSize(bool $preferCSSPageSize = true)

Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.

PDF
landscape(bool $landscape = true)

Paper orientation

PDF
scale(float $scale = 1.0)

Sets the document scaling factor

static string[]
units()

Get a list of supported units

static string[]
formats()

Get a list of supported paper formats

PDF
setTag(string $tag, string|null $value)

Sets a PDF meta tag

string|null
getTag(string $tag, string|null $default = null)

Gets a PDF meta tag value

PDF
author(string $author)

Sets the PDF author meta

PDF
description(string $description)

Sets the PDF description meta

void
keywords(array $keywords)

Sets the PDF keywords meta

PDF
keyword(string $keyword)

Adds a PDF meta keyword

PDF
creator(string $creator)

Sets the PDF content creator meta

PDF
application(string $application)

Sets the PDF application meta

PDF
created(DateTime $date)

Sets the PDF creation date

PDF
modified(DateTime $date)

Sets the PDF last modified date

Details

at line 80
protected __construct(string $url, array $options = [])

Parameters

string $url
array $options

in Renderer at line 62
protected ResponseInterface fetch()

Return Value

ResponseInterface

in Renderer at line 93
protected Renderer setOption(string $key, mixed $value)

Set option

Parameters

string $key
mixed $value

Return Value

Renderer

in Renderer at line 108
protected getOption(string $key, $default = null)

Parameters

string $key
$default

in Renderer at line 123
Renderer devicePixelRatio(float $pixelRatio = 1.0)

Sets the devicePixelRatio of the viewport

Parameters

float $pixelRatio

Return Value

Renderer

in Renderer at line 133
Renderer waitUntilLoaded()

Waits until the entire document, including resources are fully loaded.

Return Value

Renderer

in Renderer at line 143
Renderer waitUntiDOMContentLoaded()

Waits until the 'DOMContentLoaded' event is fired.

Return Value

Renderer

in Renderer at line 153
Renderer waitUntiNetworkIdle()

Waits until there has not been any network requests for at least 500ms

Return Value

Renderer

in Renderer at line 163
Renderer waitUntiNetworkSettled()

Waits until there has not been more than 2 network requests for at least 500ms

Return Value

Renderer

in Renderer at line 174
Renderer timeout(int $timeout)

Maximum amount of time to wait before timing out in milliseconds. Defaults to 30000

Parameters

int $timeout

Return Value

Renderer

in Renderer at line 184
resource stream()

Get the rendered content as a file handle (resource)

Return Value

resource

in Renderer at line 197
string|null blob()

Get the rendered content as a blob

Return Value

string|null

in Renderer at line 212
Response download(string $filename = null)

Retrieve the rendered content as a download response

Parameters

string $filename

Return Value

Response

in Renderer at line 237
Response toResponse(Request $request = null)

Retrieve the rendered content as a response

Parameters

Request $request

Return Value

Response

Retrieve URL to the rendered content

Return Value

string

at line 597
protected ResponseInterface postProcess(ResponseInterface $response)

Postprocessing stage

Parameters

ResponseInterface $response

Return Value

ResponseInterface

in Renderer at line 287
static Renderer url(string $url)

Render from url external or interal

Parameters

string $url

Return Value

Renderer

in Renderer at line 302
static Renderer from(HtmlString|string $html)

Render from raw markup

Parameters

HtmlString|string $html

Return Value

Renderer

in Renderer at line 319
static Renderer view(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Render from a view

Parameters

View|string $view
Arrayable|array $data
array $mergeData

Return Value

Renderer

in Renderer at line 336
static Renderer route(array|string $name = null, mixed $parameters = [], bool $absolute = true)

Render from named route.

Parameters

array|string $name
mixed $parameters
bool $absolute

Return Value

Renderer

in Renderer at line 344
array __debugInfo()

Return Value

array

in Renderer at line 352
string __toString()

Return Value

string

in Renderer at line 360
string jsonSerialize()

Return Value

string

in Renderer at line 369
string toJson(int $options = 0)

Parameters

int $options

Return Value

string

at line 94
final protected string getVersion()

Gets the application version string

Return Value

string

at line 107
PDF displayHeaderFooter(bool $displayHeaderFooter = true)

Enable the display of header and footer

Parameters

bool $displayHeaderFooter

Return Value

PDF

at line 118
PDF headerTemplateFrom(HtmlString|string $template)

Sets the HTML template for the print header.

Parameters

HtmlString|string $template

Return Value

PDF

at line 137
PDF headerTemplate(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Sets the HTML template for the print header from a blade view

Parameters

View|string $view
Arrayable|array $data
array $mergeData

Return Value

PDF

at line 154
PDF footerTemplateFrom(HtmlString|string $template)

Sets the HTML template for the print footer.

Parameters

HtmlString|string $template

Return Value

PDF

at line 173
PDF footerTemplate(View|string $view, Arrayable|array $data = [], array $mergeData = [])

Sets the HTML template for the print footer from a blade view

Parameters

View|string $view
Arrayable|array $data
array $mergeData

Return Value

PDF

at line 190
PDF pageRanges(array|int ...$ranges)

Paper ranges to print, e.g., [1, 5], 8, [11, 13]

Parameters

array|int ...$ranges

Return Value

PDF

at line 212
PDF printBackground(bool $printBackground = true)

Print background graphics. Defaults to false

Parameters

bool $printBackground

Return Value

PDF

at line 224
PDF marginTop(int|string $marginTop, string $unit = PDF::UNIT_CM)

Paper top margin

Parameters

int|string $marginTop
string $unit

Return Value

PDF

at line 238
PDF marginRight(int|string $marginRight, string $unit = PDF::UNIT_CM)

Paper right margin

Parameters

int|string $marginRight
string $unit

Return Value

PDF

at line 252
PDF marginBottom(int|string $marginBottom, string $unit = PDF::UNIT_CM)

Paper bottom margin

Parameters

int|string $marginBottom
string $unit

Return Value

PDF

at line 266
PDF marginLeft(int|string $marginLeft, string $unit = PDF::UNIT_CM)

Paper left margin

Parameters

int|string $marginLeft
string $unit

Return Value

PDF

at line 279
PDF margin(int|string ...$values)

Paper margins

Parameters

int|string ...$values

Return Value

PDF

at line 312
PDF format(string $format = PDF::FORMAT_A4)

Paper format. If set, takes priority over width or height options. Defaults to 'A4'

Parameters

string $format

Return Value

PDF

at line 333
static protected int|string appendUnit(int|string $value, string|null $unit = null)

Appends the given unit to value if the unit is valid

Parameters

int|string $value
string|null $unit

Return Value

int|string

at line 356
PDF emulatedMedia(string|null $media = null)

Sets the media emulation. Defaults to NULL

Parameters

string|null $media 'screen', 'print', or NULL

Return Value

PDF

at line 371
PDF width(int $width)

Paper width

Parameters

int $width

Return Value

PDF

at line 390
PDF height(int $height)

Paper height

Parameters

int $height

Return Value

PDF

at line 409
PDF preferCSSPageSize(bool $preferCSSPageSize = true)

Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.

Parameters

bool $preferCSSPageSize

Return Value

PDF

at line 420
PDF landscape(bool $landscape = true)

Paper orientation

Parameters

bool $landscape

Return Value

PDF

at line 431
PDF scale(float $scale = 1.0)

Sets the document scaling factor

Parameters

float $scale Between 0.1 - 2.0

Return Value

PDF

at line 441
static string[] units()

Get a list of supported units

Return Value

string[]

at line 456
static string[] formats()

Get a list of supported paper formats

Return Value

string[]

at line 480
protected PDF setTag(string $tag, string|null $value)

Sets a PDF meta tag

Parameters

string $tag
string|null $value

Return Value

PDF

at line 493
protected string|null getTag(string $tag, string|null $default = null)

Gets a PDF meta tag value

Parameters

string $tag
string|null $default

Return Value

string|null

at line 504
PDF author(string $author)

Sets the PDF author meta

Parameters

string $author

Return Value

PDF

at line 515
PDF description(string $description)

Sets the PDF description meta

Parameters

string $description

Return Value

PDF

at line 526
void keywords(array $keywords)

Sets the PDF keywords meta

Parameters

array $keywords

Return Value

void

at line 537
PDF keyword(string $keyword)

Adds a PDF meta keyword

Parameters

string $keyword

Return Value

PDF

at line 551
PDF creator(string $creator)

Sets the PDF content creator meta

Parameters

string $creator

Return Value

PDF

at line 562
PDF application(string $application)

Sets the PDF application meta

Parameters

string $application

Return Value

PDF

at line 573
PDF created(DateTime $date)

Sets the PDF creation date

Parameters

DateTime $date

Return Value

PDF

at line 585
PDF modified(DateTime $date)

Sets the PDF last modified date

Parameters

DateTime $date

Return Value

PDF