TCPDF
extends AbstractRenderer
in package
implements
WriterInterface
TCPDF writer.
Use DomPDF
or MPDF
instead.
Tags
Table of Contents
Interfaces
- WriterInterface
- Writer interface.
Properties
- $font : string
- Font.
- $includeFile : string
- Name of renderer include file.
- $isPdf : bool
- Is the current writer creating PDF?
- $mediaPaths : array<string|int, mixed>
- Paths to store media files.
- $notes : array<string|int, mixed>
- Footnotes and endnotes collection.
- $orientation : string
- Orientation.
- $paperSize : int
- Paper size.
- $paperSizes : array<string|int, mixed>
- Paper Sizes xRef List.
- $parts : array<string|int, mixed>
- Part name and file name pairs.
- $phpWord : PhpWord
- PHPWord object.
- $tempDir : string
- Temporary storage directory.
- $writerParts : array<string|int, mixed>
- Individual writers.
- $defaultGenericFont : string
- Default generic name for default font for html.
- $defaultWhiteSpace : string
- Default white space style for html.
- $diskCachingDirectory : string
- Disk caching directory.
- $editCallback : null|callable
- Callback for editing generated html.
- $originalFilename : string
- Original file name.
- $tempFilename : string
- Temporary file name.
- $useDiskCaching : bool
- Use disk caching.
Methods
- __construct() : mixed
- Create new instance.
- addNote() : void
- Add note.
- escapeHTML() : string
- Escape string or not depending on setting.
- getContent() : string
- Get content.
- getDefaultGenericFont() : string
- Get generic name for default font for html.
- getDefaultWhiteSpace() : string
- Get default white space style for html.
- getDiskCachingDirectory() : string
- Get disk caching directory.
- getEditCallback() : callable|null
- Return the callback to edit the entire HTML.
- getFont() : string
- Get Font.
- getNotes() : array<string|int, mixed>
- Get notes.
- getOrientation() : string
- Get Orientation.
- getPaperSize() : int
- Get Paper Size.
- getPhpWord() : PhpWord
- Get PhpWord object.
- getTempDir() : string
- Get temporary directory.
- getWriterPart() : mixed
- Get writer part.
- isPdf() : bool
- Get is PDF.
- isUseDiskCaching() : bool
- Get use disk caching status.
- save() : void
- Save PhpWord to file.
- setDefaultGenericFont() : self
- Set generic name for default font for html.
- setDefaultWhiteSpace() : self
- Set default white space style for html.
- setEditCallback() : self
- Set a callback to edit the entire HTML.
- setFont() : self
- Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.
- setOrientation() : self
- Set Orientation.
- setPaperSize() : self
- Set Paper Size.
- setPhpWord() : self
- Set PhpWord object.
- setTempDir() : self
- Set temporary directory.
- setUseDiskCaching() : self
- Set use disk caching status.
- addFilesToPackage() : void
- Add files to package.
- addFileToPackage() : void
- Add file to package.
- cleanupTempFile() : void
- Cleanup temporary file.
- clearTempDir() : void
- Clear temporary directory.
- createExternalWriterInstance() : TCPDF
- Gets the implementation of external PDF library that should be used.
- getTempFile() : string
- Get temporary file name.
- getZipArchive() : ZipArchive
- Get ZipArchive object.
- openFile() : resource
- Open file for writing.
- prepareForSave() : resource
- Save PhpWord to PDF file, pre-save.
- prepareToWrite() : void
- Overwriteable function to allow user to extend TCPDF.
- restoreStateAfterSave() : void
- Save PhpWord to PDF file, post-save.
- writeFile() : void
- Write content to file.
- deleteDir() : void
- Delete directory.
Properties
$font
Font.
protected
string
$font
$includeFile
Name of renderer include file.
protected
string
$includeFile
= 'tcpdf.php'
$isPdf
Is the current writer creating PDF?
protected
bool
$isPdf
= false
$mediaPaths
Paths to store media files.
protected
array<string|int, mixed>
$mediaPaths
= ['image' => '', 'object' => '']
$notes
Footnotes and endnotes collection.
protected
array<string|int, mixed>
$notes
= []
$orientation
Orientation.
protected
string
$orientation
$paperSize
Paper size.
protected
int
$paperSize
$paperSizes
Paper Sizes xRef List.
protected
static array<string|int, mixed>
$paperSizes
= [9 => 'A4']
$parts
Part name and file name pairs.
protected
array<string|int, mixed>
$parts
= []
$phpWord
PHPWord object.
protected
PhpWord
$phpWord
$tempDir
Temporary storage directory.
protected
string
$tempDir
= ''
$writerParts
Individual writers.
protected
array<string|int, mixed>
$writerParts
= []
$defaultGenericFont
Default generic name for default font for html.
private
string
$defaultGenericFont
= ''
$defaultWhiteSpace
Default white space style for html.
private
string
$defaultWhiteSpace
= ''
$diskCachingDirectory
Disk caching directory.
private
string
$diskCachingDirectory
= './'
$editCallback
Callback for editing generated html.
private
null|callable
$editCallback
$originalFilename
Original file name.
private
string
$originalFilename
$tempFilename
Temporary file name.
private
string
$tempFilename
$useDiskCaching
Use disk caching.
private
bool
$useDiskCaching
= false
Methods
__construct()
Create new instance.
public
__construct(PhpWord $phpWord) : mixed
Parameters
- $phpWord : PhpWord
-
PhpWord object
addNote()
Add note.
public
addNote(int $noteId, string $noteMark) : void
Parameters
- $noteId : int
- $noteMark : string
escapeHTML()
Escape string or not depending on setting.
public
escapeHTML(string $txt) : string
Parameters
- $txt : string
Return values
stringgetContent()
Get content.
public
getContent() : string
Tags
Return values
stringgetDefaultGenericFont()
Get generic name for default font for html.
public
getDefaultGenericFont() : string
Return values
stringgetDefaultWhiteSpace()
Get default white space style for html.
public
getDefaultWhiteSpace() : string
Return values
stringgetDiskCachingDirectory()
Get disk caching directory.
public
getDiskCachingDirectory() : string
Return values
stringgetEditCallback()
Return the callback to edit the entire HTML.
public
getEditCallback() : callable|null
Return values
callable|nullgetFont()
Get Font.
public
getFont() : string
Return values
stringgetNotes()
Get notes.
public
getNotes() : array<string|int, mixed>
Return values
array<string|int, mixed>getOrientation()
Get Orientation.
public
getOrientation() : string
Return values
stringgetPaperSize()
Get Paper Size.
public
getPaperSize() : int
Return values
intgetPhpWord()
Get PhpWord object.
public
getPhpWord() : PhpWord
Return values
PhpWordgetTempDir()
Get temporary directory.
public
getTempDir() : string
Return values
stringgetWriterPart()
Get writer part.
public
getWriterPart([string $partName = '' ]) : mixed
Parameters
- $partName : string = ''
-
Writer part name
isPdf()
Get is PDF.
public
isPdf() : bool
Return values
boolisUseDiskCaching()
Get use disk caching status.
public
isUseDiskCaching() : bool
Return values
boolsave()
Save PhpWord to file.
public
save(string $filename) : void
Parameters
- $filename : string
setDefaultGenericFont()
Set generic name for default font for html.
public
setDefaultGenericFont(string $value) : self
Parameters
- $value : string
Return values
selfsetDefaultWhiteSpace()
Set default white space style for html.
public
setDefaultWhiteSpace(string $value) : self
Parameters
- $value : string
Return values
selfsetEditCallback()
Set a callback to edit the entire HTML.
public
setEditCallback(callable|null $callback) : self
The callback must accept the HTML as string as first parameter, and it must return the edited HTML as string.
Parameters
- $callback : callable|null
Return values
selfsetFont()
Set font. Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.
public
setFont(string $fontName) : self
Parameters
- $fontName : string
Return values
selfsetOrientation()
Set Orientation.
public
setOrientation([string $value = 'default' ]) : self
Parameters
- $value : string = 'default'
-
Page orientation ORIENTATION_DEFAULT
Return values
selfsetPaperSize()
Set Paper Size.
public
setPaperSize([int $value = 9 ]) : self
Parameters
- $value : int = 9
-
Paper size = PAPERSIZE_A4
Return values
selfsetPhpWord()
Set PhpWord object.
public
setPhpWord([PhpWord|null $phpWord = null ]) : self
Parameters
- $phpWord : PhpWord|null = null
Return values
selfsetTempDir()
Set temporary directory.
public
setTempDir(string $value) : self
Parameters
- $value : string
Return values
selfsetUseDiskCaching()
Set use disk caching status.
public
setUseDiskCaching([bool $value = false ][, string $directory = null ]) : self
Parameters
- $value : bool = false
- $directory : string = null
Return values
selfaddFilesToPackage()
Add files to package.
protected
addFilesToPackage(ZipArchive $zip, mixed $elements) : void
Parameters
- $zip : ZipArchive
- $elements : mixed
addFileToPackage()
Add file to package.
protected
addFileToPackage(ZipArchive $zipPackage, string $source, string $target) : void
Get the actual source from an archive image.
Parameters
- $zipPackage : ZipArchive
- $source : string
- $target : string
cleanupTempFile()
Cleanup temporary file.
protected
cleanupTempFile() : void
clearTempDir()
Clear temporary directory.
protected
clearTempDir() : void
createExternalWriterInstance()
Gets the implementation of external PDF library that should be used.
protected
createExternalWriterInstance(string $orientation, string $unit, string $paperSize) : TCPDF
Parameters
- $orientation : string
-
Page orientation
- $unit : string
-
Unit measure
- $paperSize : string
-
Paper size
Return values
TCPDF —implementation
getTempFile()
Get temporary file name.
protected
getTempFile(string $filename) : string
If $filename is php://output or php://stdout, make it a temporary file
Parameters
- $filename : string
Return values
stringgetZipArchive()
Get ZipArchive object.
protected
getZipArchive(string $filename) : ZipArchive
Parameters
- $filename : string
Return values
ZipArchiveopenFile()
Open file for writing.
protected
openFile(string $filename) : resource
Parameters
- $filename : string
Tags
Return values
resourceprepareForSave()
Save PhpWord to PDF file, pre-save.
protected
prepareForSave([string $filename = null ]) : resource
Parameters
- $filename : string = null
-
Name of the file to save as
Return values
resourceprepareToWrite()
Overwriteable function to allow user to extend TCPDF.
protected
prepareToWrite(TCPDF $pdf) : void
There should always be an AddPage call, preceded or followed by code to customize TCPDF configuration. The customization below sets vertical spacing between paragaraphs when the user has explicitly set those values to numeric in default style.
Parameters
- $pdf : TCPDF
restoreStateAfterSave()
Save PhpWord to PDF file, post-save.
protected
restoreStateAfterSave(resource $fileHandle) : void
Parameters
- $fileHandle : resource
writeFile()
Write content to file.
protected
writeFile(resource $fileHandle, string $content) : void
Parameters
- $fileHandle : resource
- $content : string
Tags
deleteDir()
Delete directory.
private
deleteDir(string $dir) : void
Parameters
- $dir : string