DompdfWrapper
Wrapper sur l'interface publique de la classe utilitaire Dompdf.
(permet d'exposer les méthodes dans un service Symfony)
Table of Contents
Properties
- $dompdf : mixed
Methods
- addInfo() : void
- Add meta information to the PDF after rendering.
- construct() : mixed
- Class constructor
- enableCaching() : mixed
- Enable experimental caching capability
- getBaseHost() : string
- Returns the base hostname
- getBasePath() : string
- Returns the base path
- getCallbacks() : array<string|int, mixed>
- Returns the callbacks array
- getCanvas() : Canvas
- Return the underlying Canvas instance (e.g. Dompdf\Adapter\CPDF, Dompdf\Adapter\GD)
- getCss() : Stylesheet
- Returns the stylesheet
- getDom() : DOMDocument
- getFontMetrics() : FontMetrics
- getHttpContext() : resource
- Returns the HTTP context
- getOptions() : Options
- getPaperOrientation() : string
- Gets the paper orientation
- getPaperSize() : array<string|int, float>
- Gets the paper size
- getProtocol() : string
- Returns the protocol in use
- getQuirksmode() : bool
- Get the quirks mode
- getTree() : FrameTree
- Returns the underlying {@link FrameTree} object
- loadDOM() : mixed
- loadHtml() : mixed
- Loads an HTML string Parse errors are stored in the global array _dompdf_warnings.
- loadHtmlFile() : mixed
- Loads an HTML file Parse errors are stored in the global array _dompdf_warnings.
- output() : string|null
- Returns the PDF as a string.
- outputHtml() : string
- Returns the underlying HTML document as a string
- parseDefaultView() : bool
- removeTextNodes() : mixed
- render() : mixed
- Renders the HTML to PDF
- setBaseHost() : $this
- Sets the base hostname
- setBasePath() : $this
- Sets the base path
- setCallbacks() : $this
- Define callbacks that allow modifying the document during render.
- setCanvas() : $this
- Set a custom `Canvas` instance to render the document to.
- setCss() : $this
- setDefaultView() : $this
- Sets the default view
- setDom() : $this
- setFontMetrics() : $this
- setHttpContext() : $this
- Sets the HTTP context
- setOptions() : $this
- setPaper() : $this
- Sets the paper size & orientation
- setProtocol() : $this
- Sets the protocol to use FIXME validate these
- setTree() : $this
- stream() : mixed
- Streams the PDF to the client.
Properties
$dompdf
protected
mixed
$dompdf
Methods
addInfo()
Add meta information to the PDF after rendering.
public
addInfo(string $label, string $value) : void
Parameters
- $label : string
-
Label of the value (Creator, Producer, etc.)
- $value : string
-
The text to set
construct()
Class constructor
public
construct([Options|array<string|int, mixed>|null $options = null ]) : mixed
Parameters
- $options : Options|array<string|int, mixed>|null = null
enableCaching()
Enable experimental caching capability
public
enableCaching(string $cacheId) : mixed
Parameters
- $cacheId : string
getBaseHost()
Returns the base hostname
public
getBaseHost() : string
Return values
stringgetBasePath()
Returns the base path
public
getBasePath() : string
Return values
stringgetCallbacks()
Returns the callbacks array
public
getCallbacks() : array<string|int, mixed>
Return values
array<string|int, mixed>getCanvas()
Return the underlying Canvas instance (e.g. Dompdf\Adapter\CPDF, Dompdf\Adapter\GD)
public
getCanvas() : Canvas
Return values
CanvasgetCss()
Returns the stylesheet
public
getCss() : Stylesheet
Return values
StylesheetgetDom()
public
getDom() : DOMDocument
Return values
DOMDocumentgetFontMetrics()
public
getFontMetrics() : FontMetrics
Return values
FontMetricsgetHttpContext()
Returns the HTTP context
public
getHttpContext() : resource
Return values
resourcegetOptions()
public
getOptions() : Options
Return values
OptionsgetPaperOrientation()
Gets the paper orientation
public
getPaperOrientation() : string
Return values
string —Either "portrait" or "landscape"
getPaperSize()
Gets the paper size
public
getPaperSize() : array<string|int, float>
Return values
array<string|int, float> —A four-element float array
getProtocol()
Returns the protocol in use
public
getProtocol() : string
Return values
stringgetQuirksmode()
Get the quirks mode
public
getQuirksmode() : bool
Return values
bool —true if quirks mode is active
getTree()
Returns the underlying {@link FrameTree} object
public
getTree() : FrameTree
Return values
FrameTreeloadDOM()
public
loadDOM(mixed $doc[, mixed $quirksmode = false ]) : mixed
Parameters
- $doc : mixed
- $quirksmode : mixed = false
loadHtml()
Loads an HTML string Parse errors are stored in the global array _dompdf_warnings.
public
loadHtml(string $str[, string $encoding = null ]) : mixed
Parameters
- $str : string
-
HTML text to load
- $encoding : string = null
-
Encoding of $str
loadHtmlFile()
Loads an HTML file Parse errors are stored in the global array _dompdf_warnings.
public
loadHtmlFile(string $file[, string $encoding = null ]) : mixed
Parameters
- $file : string
-
a filename or url to load
- $encoding : string = null
-
Encoding of $file
Tags
output()
Returns the PDF as a string.
public
output([array<string|int, mixed> $options = [] ]) : string|null
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 : array<string|int, mixed> = []
-
options (see above)
Return values
string|nulloutputHtml()
Returns the underlying HTML document as a string
public
outputHtml() : string
Return values
stringparseDefaultView()
public
parseDefaultView(string $value) : bool
Parameters
- $value : string
Return values
boolremoveTextNodes()
public
static removeTextNodes(DOMNode $node) : mixed
Parameters
- $node : DOMNode
render()
Renders the HTML to PDF
public
render() : mixed
setBaseHost()
Sets the base hostname
public
setBaseHost(string $baseHost) : $this
Parameters
- $baseHost : string
Return values
$thissetBasePath()
Sets the base path
public
setBasePath(string $basePath) : $this
Parameters
- $basePath : string
Return values
$thissetCallbacks()
Define callbacks that allow modifying the document during render.
public
setCallbacks(array<string|int, mixed> $callbacks) : $this
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 : array<string|int, mixed>
-
The set of callbacks to set.
Return values
$thissetCanvas()
Set a custom `Canvas` instance to render the document to.
public
setCanvas(Canvas $canvas) : $this
Be aware that the instance will be replaced on render if the document defines a paper size different from the canvas.
Parameters
- $canvas : Canvas
Return values
$thissetCss()
public
setCss(Stylesheet $css) : $this
Parameters
- $css : Stylesheet
Return values
$thissetDefaultView()
Sets the default view
public
setDefaultView(string $defaultView, array<string|int, mixed> $options) : $this
Parameters
- $defaultView : string
-
The default document view
- $options : array<string|int, mixed>
-
The view's options
Return values
$thissetDom()
public
setDom(DOMDocument $dom) : $this
Parameters
- $dom : DOMDocument
Return values
$thissetFontMetrics()
public
setFontMetrics(FontMetrics $fontMetrics) : $this
Parameters
- $fontMetrics : FontMetrics
Return values
$thissetHttpContext()
Sets the HTTP context
public
setHttpContext(resource|array<string|int, mixed> $httpContext) : $this
Parameters
- $httpContext : resource|array<string|int, mixed>
Return values
$thissetOptions()
public
setOptions(Options $options) : $this
Parameters
- $options : Options
Return values
$thissetPaper()
Sets the paper size & orientation
public
setPaper(string|array<string|int, float> $size[, string $orientation = "portrait" ]) : $this
Parameters
- $size : string|array<string|int, float>
-
- $orientation : string = "portrait"
-
'portrait' or 'landscape'
Return values
$thissetProtocol()
Sets the protocol to use FIXME validate these
public
setProtocol(string $protocol) : $this
Parameters
- $protocol : string
Return values
$thissetTree()
public
setTree(FrameTree $tree) : $this
Parameters
- $tree : FrameTree
Return values
$thisstream()
Streams the PDF to the client.
public
stream([string $filename = "document.pdf" ][, array<string|int, mixed> $options = [] ]) : mixed
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 : string = "document.pdf"
-
the name of the streamed file
- $options : array<string|int, mixed> = []
-
header options (see above)