Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf Class Reference
Inheritance diagram for PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf:
PhpOffice\PhpSpreadsheet\Writer\Pdf PhpOffice\PhpSpreadsheet\Writer\Html PhpOffice\PhpSpreadsheet\Writer\BaseWriter PhpOffice\PhpSpreadsheet\Writer\IWriter

Public Member Functions

 __construct (Spreadsheet $spreadsheet)
 Create a new PDF Writer instance.
 
 buildCSS (bool $generateSurroundingHTML=true)
 Build CSS styles.
 
 formatColor (string $value, string $format)
 Add color to formatted string as inline style.
 
 generateHtmlAll ()
 Save Spreadsheet as html to variable.
 
 generateHTMLFooter ()
 Generate HTML footer.
 
 generateHTMLHeader (bool $includeStyles=false)
 Generate HTML header.
 
 generateNavigation ()
 Generate sheet tabs.
 
 generateSheetData ()
 Generate sheet data.
 
 generateStyles (bool $generateSurroundingHTML=true)
 Generate CSS styles.
 
 getBetterBoolean ()
 
 getDiskCachingDirectory ()
 Get disk caching directory.
 
 getEmbedImages ()
 Get embed images.
 
 getFont ()
 Get Font.
 
 getGenerateSheetNavigationBlock ()
 Get sheet index.
 
 getImagesRoot ()
 Get images root.
 
 getIncludeCharts ()
 Write charts in workbook?
 
 getOrientation ()
 Get Orientation.
 
 getPaperSize ()
 Get Paper Size.
 
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save.
 
 getSheetIndex ()
 Get sheet index.
 
 getTempDir ()
 Get temporary storage directory.
 
 getUseDiskCaching ()
 Get use disk caching where possible?
 
 getUseInlineCss ()
 Get use inline CSS?
 
 openFileHandle ($filename)
 Open file handle.
 
 save ($filename, int $flags=0)
 Save Spreadsheet to file.
 
 setBetterBoolean (bool $betterBoolean)
 
 setEditHtmlCallback (?callable $callback)
 Set a callback to edit the entire HTML.
 
 setEmbedImages (bool $embedImages)
 Set embed images.
 
 setFont (string $fontName)
 Set font.
 
 setGenerateSheetNavigationBlock (bool $generateSheetNavigationBlock)
 Set sheet index.
 
 setImagesRoot (string $imagesRoot)
 Set images root.
 
 setIncludeCharts (bool $includeCharts)
 Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
 
 setOrientation (string $orientation)
 Set Orientation.
 
 setPaperSize (int $paperSize)
 Set Paper Size.
 
 setPreCalculateFormulas (bool $precalculateFormulas)
 Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save.
 
 setSheetIndex (int $sheetIndex)
 Set sheet index.
 
 setTempDir (string $temporaryDirectory)
 Set temporary storage directory.
 
 setUseDiskCaching (bool $useDiskCache, ?string $cacheDirectory=null)
 Set use disk caching where possible?
 
 setUseInlineCss (bool $useInlineCss)
 Set use inline CSS?
 
 writeAllSheets ()
 Write all sheets (resets sheetIndex to NULL).
 

Static Public Member Functions

static formatColorStatic (string $value, string $format)
 Add color to formatted string as inline style.
 
static winFileToUrl (string $filename, bool $mpdf=false)
 Convert Windows file name to file protocol URL.
 

Public Attributes

const BODY_LINE = ' <body>' . PHP_EOL
 
const BORDER_ARR
 
const BORDER_NONE = 'none'
 
const COMMENT_HTML_TAGS_PLAINTEXT = true
 
const DISABLE_PRECALCULATE_FORMULAE = 2
 
const SAVE_WITH_CHARTS = 1
 

Protected Member Functions

 createExternalWriterInstance (string $orientation, string $unit, $paperSize)
 Gets the implementation of external PDF library that should be used.
 
 maybeCloseFileHandle ()
 Close file handle only if we opened it ourselves.
 
 prepareForSave ($filename)
 Save Spreadsheet to PDF file, pre-save.
 
 processFlags (int $flags)
 
 restoreStateAfterSave ()
 Save PhpSpreadsheet to PDF file, post-save.
 

Protected Attributes

bool $embedImages = false
 embed images, or link to images.
 
resource $fileHandle
 
string $font = 'freesans'
 Font.
 
bool $includeCharts = false
 
bool $isPdf = false
 Is the current writer creating PDF?
 
string $orientation = null
 Orientation (Over-ride).
 
int $paperSize = null
 Paper size (Over-ride).
 
bool $preCalculateFormulas = true
 Pre-calculate formulas Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file.
 
Spreadsheet $spreadsheet
 Spreadsheet object.
 
string $tempDir
 

Static Protected Attributes

static array $paperSizes
 Paper Sizes xRef List.
 

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::__construct ( Spreadsheet $spreadsheet)

Create a new PDF Writer instance.

Parameters
Spreadsheet$spreadsheetSpreadsheet object

Reimplemented from PhpOffice\PhpSpreadsheet\Writer\Pdf.

Member Function Documentation

◆ buildCSS()

PhpOffice\PhpSpreadsheet\Writer\Html::buildCSS ( bool $generateSurroundingHTML = true)
inherited

Build CSS styles.

Parameters
bool$generateSurroundingHTMLGenerate surrounding HTML style? (html { })

◆ createExternalWriterInstance()

PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::createExternalWriterInstance ( string $orientation,
string $unit,
$paperSize )
protected

Gets the implementation of external PDF library that should be used.

Parameters
string$orientationPage orientation
string$unitUnit measure
array | string$paperSizePaper size
Return values
TCPDFimplementation

◆ formatColor()

PhpOffice\PhpSpreadsheet\Writer\Html::formatColor ( string $value,
string $format )
inherited

Add color to formatted string as inline style.

Parameters
string$valuePlain formatted value without color
string$formatFormat code

◆ formatColorStatic()

static PhpOffice\PhpSpreadsheet\Writer\Html::formatColorStatic ( string $value,
string $format )
staticinherited

Add color to formatted string as inline style.

Parameters
string$valuePlain formatted value without color
string$formatFormat code

◆ generateHTMLHeader()

PhpOffice\PhpSpreadsheet\Writer\Html::generateHTMLHeader ( bool $includeStyles = false)
inherited

Generate HTML header.

Parameters
bool$includeStylesInclude styles?

◆ generateStyles()

PhpOffice\PhpSpreadsheet\Writer\Html::generateStyles ( bool $generateSurroundingHTML = true)
inherited

Generate CSS styles.

Parameters
bool$generateSurroundingHTMLGenerate surrounding HTML tags? (<style> and </style>)

◆ getDiskCachingDirectory()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::getDiskCachingDirectory ( )
inherited

Get disk caching directory.

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ getIncludeCharts()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::getIncludeCharts ( )
inherited

Write charts in workbook?

If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object. If false (the default) it will ignore any charts defined in the PhpSpreadsheet object.

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ getOrientation()

PhpOffice\PhpSpreadsheet\Writer\Pdf::getOrientation ( )
inherited

Get Orientation.

Reimplemented from PhpOffice\PhpSpreadsheet\Writer\Html.

◆ getPreCalculateFormulas()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::getPreCalculateFormulas ( )
inherited

Get Pre-Calculate Formulas flag If this is true (the default), then the writer will recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file If false, then formulae are not calculated on save.

This is faster for saving in PhpSpreadsheet, but slower when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ getUseDiskCaching()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::getUseDiskCaching ( )
inherited

Get use disk caching where possible?

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ openFileHandle()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::openFileHandle ( $filename)
inherited

Open file handle.

Parameters
resource | string$filename

◆ prepareForSave()

PhpOffice\PhpSpreadsheet\Writer\Pdf::prepareForSave ( $filename)
protectedinherited

Save Spreadsheet to PDF file, pre-save.

Parameters
resource | string$filenameName of the file to save as
Return values
resource

◆ save()

PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf::save ( $filename,
int $flags = 0 )

Save Spreadsheet to file.

Parameters
string$filenameName of the file to save as

Reimplemented from PhpOffice\PhpSpreadsheet\Writer\Html.

◆ setEditHtmlCallback()

PhpOffice\PhpSpreadsheet\Writer\Html::setEditHtmlCallback ( ?callable $callback)
inherited

Set a callback to edit the entire HTML.

The callback must accept the HTML as string as first parameter, and it must return the edited HTML as string.

◆ setEmbedImages()

PhpOffice\PhpSpreadsheet\Writer\Html::setEmbedImages ( bool $embedImages)
inherited

Set embed images.

Return values
$this

◆ setFont()

PhpOffice\PhpSpreadsheet\Writer\Pdf::setFont ( string $fontName)
inherited

Set font.

Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'.

Return values
$this

◆ setGenerateSheetNavigationBlock()

PhpOffice\PhpSpreadsheet\Writer\Html::setGenerateSheetNavigationBlock ( bool $generateSheetNavigationBlock)
inherited

Set sheet index.

Parameters
bool$generateSheetNavigationBlockFlag indicating whether the sheet navigation block should be generated or not
Return values
$this

◆ setImagesRoot()

PhpOffice\PhpSpreadsheet\Writer\Html::setImagesRoot ( string $imagesRoot)
inherited

Set images root.

Return values
$this

◆ setIncludeCharts()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::setIncludeCharts ( bool $includeCharts)
inherited

Set write charts in workbook Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.

Set to false (the default) to ignore charts.

Return values
$this

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ setOrientation()

PhpOffice\PhpSpreadsheet\Writer\Pdf::setOrientation ( string $orientation)
inherited

Set Orientation.

Parameters
string$orientationPage orientation see PageSetup::ORIENTATION_*

◆ setPaperSize()

PhpOffice\PhpSpreadsheet\Writer\Pdf::setPaperSize ( int $paperSize)
inherited

Set Paper Size.

Parameters
int$paperSizePaper size see PageSetup::PAPERSIZE_*

◆ setPreCalculateFormulas()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::setPreCalculateFormulas ( bool $precalculateFormulas)
inherited

Set Pre-Calculate Formulas Set to true (the default) to advise the Writer to calculate all formulae on save Set to false to prevent precalculation of formulae on save.

Parameters
bool$precalculateFormulasPre-Calculate Formulas?
Return values
$this

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ setSheetIndex()

PhpOffice\PhpSpreadsheet\Writer\Html::setSheetIndex ( int $sheetIndex)
inherited

Set sheet index.

Parameters
int$sheetIndexSheet index
Return values
$this

◆ setTempDir()

PhpOffice\PhpSpreadsheet\Writer\Pdf::setTempDir ( string $temporaryDirectory)
inherited

Set temporary storage directory.

Parameters
string$temporaryDirectoryTemporary storage directory

◆ setUseDiskCaching()

PhpOffice\PhpSpreadsheet\Writer\BaseWriter::setUseDiskCaching ( bool $useDiskCache,
?string $cacheDirectory = null )
inherited

Set use disk caching where possible?

Parameters
?string$cacheDirectoryDisk caching directory
Return values
$this

Implements PhpOffice\PhpSpreadsheet\Writer\IWriter.

◆ setUseInlineCss()

PhpOffice\PhpSpreadsheet\Writer\Html::setUseInlineCss ( bool $useInlineCss)
inherited

Set use inline CSS?

Return values
$this

◆ winFileToUrl()

static PhpOffice\PhpSpreadsheet\Writer\Html::winFileToUrl ( string $filename,
bool $mpdf = false )
staticinherited

Convert Windows file name to file protocol URL.

Parameters
string$filenamefile name on local system

◆ writeAllSheets()

PhpOffice\PhpSpreadsheet\Writer\Html::writeAllSheets ( )
inherited

Write all sheets (resets sheetIndex to NULL).

Return values
$this

Member Data Documentation

◆ BORDER_ARR

const PhpOffice\PhpSpreadsheet\Writer\Html::BORDER_ARR
inherited
Initial value:
= [
Border::BORDER_NONE => self::BORDER_NONE,
Border::BORDER_DASHDOT => '1px dashed',
Border::BORDER_DASHDOTDOT => '1px dotted',
Border::BORDER_DASHED => '1px dashed',
Border::BORDER_DOTTED => '1px dotted',
Border::BORDER_DOUBLE => '3px double',
Border::BORDER_HAIR => '1px solid',
Border::BORDER_MEDIUM => '2px solid',
Border::BORDER_MEDIUMDASHDOT => '2px dashed',
Border::BORDER_MEDIUMDASHDOTDOT => '2px dotted',
Border::BORDER_SLANTDASHDOT => '2px dashed',
Border::BORDER_THICK => '3px solid',
]

The documentation for this class was generated from the following file: