| Methods |
public
|
construct(Options|array|null $options = null)
Class constructor
|
#
|
public
|
loadDOM($doc, $quirksmode = false)
|
#
|
public
|
loadHtmlFile(string $file, string $encoding = null)
Loads an HTML file
Parse errors are stored in the global array _dompdf_warnings.
Loads an HTML file
Parse errors are stored in the global array _dompdf_warnings.
Parameters
| $file |
a filename or url to load
|
| $encoding |
Encoding of $file
|
Throws
TIC\DpdfBundle\Traits\Exception |
|
|
#
|
public
|
loadHtml(string $str, string $encoding = null)
Loads an HTML string
Parse errors are stored in the global array _dompdf_warnings.
Loads an HTML string
Parse errors are stored in the global array _dompdf_warnings.
Parameters
| $str |
HTML text to load
|
| $encoding |
Encoding of $str
|
|
#
|
public
static
|
removeTextNodes(DOMNode $node)
|
#
|
public
|
enableCaching(string $cacheId)
Enable experimental caching capability
Enable experimental caching capability
|
#
|
public
|
parseDefaultView(string $value): bool
|
#
|
public
|
render()
Renders the HTML to PDF
|
#
|
public
|
addInfo(string $label, string $value): void
Add meta information to the PDF after rendering.
Add meta information to the PDF after rendering.
Parameters
| $label |
Label of the value (Creator, Producer, etc.)
|
| $value |
The text to set
|
|
#
|
public
|
stream(string $filename = "document.pdf", array $options = [])
Streams the PDF to the client.
Streams the PDF to the client.
The file will open a download dialog by default. The options
parameter controls the output. Accepted options (array keys) are:
'compress' = > 1 (=default) or 0:
Apply content stream compression
'Attachment' => 1 (=default) or 0:
Set the 'Content-Disposition:' HTTP header to 'attachment'
(thereby causing the browser to open a download dialog)
Parameters
| $filename |
the name of the streamed file
|
| $options |
header options (see above)
|
|
#
|
public
|
output(array $options = []): string|null
Returns the PDF as a string.
Returns the PDF as a string.
The options parameter controls the output. Accepted options are:
'compress' = > 1 or 0 - apply content stream compression, this is
on (1) by default
Parameters
| $options |
options (see above)
|
|
#
|
public
|
outputHtml(): string
Returns the underlying HTML document as a string
Returns the underlying HTML document as a string
|
#
|
public
|
setPaper(string|float[] $size, string $orientation = "portrait"): $this
Sets the paper size & orientation
Sets the paper size & orientation
Parameters
| $size |
'letter', 'legal', 'A4', etc. {@link Dompdf\Adapter\CPDF::$PAPER_SIZES}
|
| $orientation |
'portrait' or 'landscape'
|
|
#
|
public
|
getPaperSize(): float[]
Gets the paper size
Returns
A four-element float array
|
#
|
public
|
getPaperOrientation(): string
Gets the paper orientation
Gets the paper orientation
Returns
Either "portrait" or "landscape"
|
#
|
public
|
setTree(FrameTree $tree): $this
|
#
|
public
|
getTree(): FrameTree
Returns the underlying {@link FrameTree} object
Returns the underlying {@link FrameTree} object
|
#
|
public
|
setProtocol(string $protocol): $this
Sets the protocol to use
FIXME validate these
Sets the protocol to use
FIXME validate these
|
#
|
public
|
getProtocol(): string
Returns the protocol in use
Returns the protocol in use
|
#
|
public
|
setBaseHost(string $baseHost): $this
Sets the base hostname
|
#
|
public
|
getBaseHost(): string
Returns the base hostname
Returns the base hostname
|
#
|
public
|
setBasePath(string $basePath): $this
Sets the base path
|
#
|
public
|
getBasePath(): string
Returns the base path
|
#
|
public
|
setDefaultView(string $defaultView, array $options): $this
Sets the default view
Parameters
| $defaultView |
The default document view
|
| $options |
The view's options
|
|
#
|
public
|
setHttpContext(resource|array $httpContext): $this
Sets the HTTP context
|
#
|
public
|
getHttpContext(): resource
Returns the HTTP context
|
#
|
public
|
setCanvas(Canvas $canvas): $this
Set a custom `Canvas` instance to render the document to.
Set a custom Canvas instance to render the document to.
Be aware that the instance will be replaced on render if the document
defines a paper size different from the canvas.
|
#
|
public
|
getCanvas(): Canvas
Return the underlying Canvas instance (e.g. Dompdf\Adapter\CPDF, Dompdf\Adapter\GD)
Return the underlying Canvas instance (e.g. Dompdf\Adapter\CPDF, Dompdf\Adapter\GD)
|
#
|
public
|
setCss(Stylesheet $css): $this
|
#
|
public
|
getCss(): Stylesheet
Returns the stylesheet
|
#
|
public
|
setDom(DOMDocument $dom): $this
|
#
|
public
|
getDom(): DOMDocument
|
#
|
public
|
setOptions(Options $options): $this
|
#
|
public
|
getOptions(): Options
|
#
|
public
|
getCallbacks(): array
Returns the callbacks array
Returns the callbacks array
|
#
|
public
|
setCallbacks(array $callbacks): $this
Define callbacks that allow modifying the document during render.
Define callbacks that allow modifying the document during render.
The callbacks array should contain arrays with event set to a callback
event name and f set to a function or any other callable.
The available callback events are:
-
begin_page_reflow: called before page reflow
-
begin_frame: called before a frame is rendered
-
end_frame: called after frame rendering is complete
-
begin_page_render: called before a page is rendered
-
end_page_render: called after page rendering is complete
-
end_document: called for every page after rendering is complete
The function f receives three arguments Frame $frame, Canvas $canvas,
and FontMetrics $fontMetrics for all events but end_document. For
end_document, the function receives four arguments int $pageNumber,
int $pageCount, Canvas $canvas, and FontMetrics $fontMetrics instead.
Parameters
| $callbacks |
The set of callbacks to set.
|
|
#
|
public
|
getQuirksmode(): boolean
Get the quirks mode
Returns
true if quirks mode is active
|
#
|
public
|
setFontMetrics(FontMetrics $fontMetrics): $this
|
#
|
public
|
getFontMetrics(): FontMetrics
|
#
|