PdfWriter
extends AbstractPdfWriter
in package
Class PdfWriter.
Use PdfCreatorFactory::createInstance(MpdfCreator::getType()) instead
Table of Contents
Constants
- OUTPUT_MODE_DOWNLOAD = 'download'
- OUTPUT_MODE_FILE = 'file'
- OUTPUT_MODE_INLINE = 'inline'
- OUTPUT_MODES = [self::OUTPUT_MODE_DOWNLOAD, self::OUTPUT_MODE_FILE, self::OUTPUT_MODE_INLINE]
Properties
- $config : array<string|int, mixed>
- Pdf configuration.
- $fileName : string
- Pdf file name.
- $folder : string
- The folder in case of saving to file.
- $html : string
- Pdf html content including styles.
- $isPrepared : bool
- $pdf : Mpdf
- Current mpdf instance.
- $template : string
- Master pdf template.
Methods
- __construct() : mixed
- constructor.
- addFontDirectories() : PdfWriter
- Add font directories to the config.
- generate() : void
- Generate the pdf.
- getConfig() : array<string|int, mixed>
- Get the pdf config.
- getFileName() : string
- Get the pdf file name.
- getFolder() : string
- getHtml() : string
- Get html including styles.
- getPdf() : Mpdf
- Get current pdf object.
- getTemplate() : string
- Get the master template path.
- isPrepared() : bool
- Check if prepare was already triggered.
- mergeConfig() : PdfWriter
- Merge current pdf config with given.
- prepare() : Mpdf
- Prepare the current mpdf object.
- setConfig() : PdfWriter
- Set pdf config, replace default with custom config.
- setDefaultConfig() : mixed
- setFileName() : PdfWriter
- Set the pdf filename.
- setFolder() : void
- setHtml() : PdfWriter
- Set html including styles.
- setTemplate() : PdfWriter
- Set the master template path.
Constants
OUTPUT_MODE_DOWNLOAD
public
mixed
OUTPUT_MODE_DOWNLOAD
= 'download'
OUTPUT_MODE_FILE
public
mixed
OUTPUT_MODE_FILE
= 'file'
OUTPUT_MODE_INLINE
public
mixed
OUTPUT_MODE_INLINE
= 'inline'
OUTPUT_MODES
public
mixed
OUTPUT_MODES
= [self::OUTPUT_MODE_DOWNLOAD, self::OUTPUT_MODE_FILE, self::OUTPUT_MODE_INLINE]
Properties
$config
Pdf configuration.
protected
array<string|int, mixed>
$config
= []
$fileName
Pdf file name.
protected
string
$fileName
$folder
The folder in case of saving to file.
protected
string
$folder
$html
Pdf html content including styles.
protected
string
$html
$isPrepared
protected
bool
$isPrepared
= false
Current mpdf instance.
protected
Mpdf
$pdf
$template
Master pdf template.
protected
string
$template
Methods
__construct()
constructor.
public
__construct() : mixed
addFontDirectories()
Add font directories to the config.
public
addFontDirectories(array<string|int, mixed> $paths) : PdfWriter
Parameters
- $paths : array<string|int, mixed>
-
Directory pathseader
Return values
PdfWriter —Current pdf writer instance
generate()
Generate the pdf.
public
generate([string $mode = self::OUTPUT_MODE_DOWNLOAD ]) : void
Parameters
- $mode : string = self::OUTPUT_MODE_DOWNLOAD
getConfig()
Get the pdf config.
public
getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>getFileName()
Get the pdf file name.
public
getFileName() : string
Return values
stringgetFolder()
public
getFolder() : string
Return values
stringgetHtml()
Get html including styles.
public
getHtml() : string
Return values
stringgetPdf()
Get current pdf object.
public
getPdf([bool $init = false ]) : Mpdf
Parameters
- $init : bool = false
-
Set true if you want to create a new pdf regardless there is always an existing pdf
Return values
MpdfgetTemplate()
Get the master template path.
public
getTemplate() : string
Return values
stringisPrepared()
Check if prepare was already triggered.
public
isPrepared() : bool
Return values
boolmergeConfig()
Merge current pdf config with given.
public
mergeConfig(array<string|int, mixed> $config) : PdfWriter
Parameters
- $config : array<string|int, mixed>
Return values
PdfWriter —Current pdf writer instance
prepare()
Prepare the current mpdf object.
public
prepare() : Mpdf
Return values
MpdfsetConfig()
Set pdf config, replace default with custom config.
public
setConfig(array<string|int, mixed> $config) : PdfWriter
Parameters
- $config : array<string|int, mixed>
Return values
PdfWriter —Current pdf writer instance
setDefaultConfig()
public
setDefaultConfig() : mixed
setFileName()
Set the pdf filename.
public
setFileName(string $fileName) : PdfWriter
Parameters
- $fileName : string
Return values
PdfWriter —Current pdf writer instance
setFolder()
public
setFolder(string $folder) : void
Parameters
- $folder : string
setHtml()
Set html including styles.
public
setHtml(string $html) : PdfWriter
Parameters
- $html : string
Return values
PdfWritersetTemplate()
Set the master template path.
public
setTemplate(string $template) : PdfWriter
Parameters
- $template : string
Return values
PdfWriter —Current pdf writer instance