abstract class Pdf extends Html (View source)

Properties

protected bool $includeCharts Write charts that are defined in the workbook? Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object;. from BaseWriter
protected bool $preCalculateFormulas 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. from BaseWriter
protected Spreadsheet $spreadsheet Spreadsheet object. from Html
protected bool $isPdf Is the current writer creating PDF? from Html
protected string $tempDir Temporary storage directory.
protected string $font Font.
protected string $orientation Orientation (Over-ride).
protected int $paperSize Paper size (Over-ride).
static protected array $paperSizes Paper Sizes xRef List.

Methods

bool
getIncludeCharts()

Write charts in workbook? If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.

setIncludeCharts(bool $pValue)

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

bool
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. 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.

setPreCalculateFormulas(bool $pValue)

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.

bool
getUseDiskCaching()

Get use disk caching where possible?

setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

string
getDiskCachingDirectory()

Get disk caching directory.

__construct(Spreadsheet $spreadsheet)

Create a new PDF Writer instance.

save(string $pFilename)

Save Spreadsheet to file.

from Html
int
getSheetIndex()

Get sheet index.

from Html
HTML
setSheetIndex(int $pValue)

Set sheet index.

from Html
bool
getGenerateSheetNavigationBlock()

Get sheet index.

from Html
HTML
setGenerateSheetNavigationBlock(bool $pValue)

Set sheet index.

from Html
writeAllSheets()

Write all sheets (resets sheetIndex to NULL).

from Html
string
generateHTMLHeader(bool $pIncludeStyles = false)

Generate HTML header.

from Html
string
generateSheetData()

Generate sheet data.

from Html
string
generateNavigation()

Generate sheet tabs.

from Html
string
generateStyles(bool $generateSurroundingHTML = true)

Generate CSS styles.

from Html
array
buildCSS(bool $generateSurroundingHTML = true)

Build CSS styles.

from Html
generateHTMLFooter()

Generate HTML footer.

from Html
string
getImagesRoot()

Get images root.

from Html
HTML
setImagesRoot(string $pValue)

Set images root.

from Html
bool
getEmbedImages()

Get embed images.

from Html
HTML
setEmbedImages(bool $pValue)

Set embed images.

from Html
bool
getUseInlineCss()

Get use inline CSS?

from Html
HTML
setUseInlineCss(bool $pValue)

Set use inline CSS?

from Html
string
formatColor(string $pValue, string $pFormat)

Add color to formatted string as inline style.

from Html
string
getFont()

Get Font.

Pdf
setFont(string $fontName)

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

int
getPaperSize()

Get Paper Size.

Pdf
setPaperSize(string $pValue)

Set Paper Size.

string
getOrientation()

Get Orientation.

Pdf
setOrientation(string $pValue)

Set Orientation.

string
getTempDir()

Get temporary storage directory.

Pdf
setTempDir(string $pValue)

Set temporary storage directory.

resource
prepareForSave(string $pFilename)

Save Spreadsheet to PDF file, pre-save.

restoreStateAfterSave(resource $fileHandle)

Save PhpSpreadsheet to PDF file, post-save.

Details

bool getIncludeCharts()

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.

Return Value

bool

IWriter setIncludeCharts(bool $pValue)

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.

Parameters

bool $pValue

Return Value

IWriter

bool 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. 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.

Return Value

bool

IWriter setPreCalculateFormulas(bool $pValue)

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 $pValue Pre-Calculate Formulas?

Return Value

IWriter

bool getUseDiskCaching()

Get use disk caching where possible?

Return Value

bool

IWriter setUseDiskCaching(bool $pValue, string $pDirectory = null)

Set use disk caching where possible?

Parameters

bool $pValue
string $pDirectory Disk caching directory

Return Value

IWriter

Exceptions

Exception when directory does not exist

string getDiskCachingDirectory()

Get disk caching directory.

Return Value

string

__construct(Spreadsheet $spreadsheet)

Create a new PDF Writer instance.

Parameters

Spreadsheet $spreadsheet

save(string $pFilename)

Save Spreadsheet to file.

Parameters

string $pFilename Name of the file to save

Exceptions

Exception

int getSheetIndex()

Get sheet index.

Return Value

int

HTML setSheetIndex(int $pValue)

Set sheet index.

Parameters

int $pValue Sheet index

Return Value

HTML

bool getGenerateSheetNavigationBlock()

Get sheet index.

Return Value

bool

HTML setGenerateSheetNavigationBlock(bool $pValue)

Set sheet index.

Parameters

bool $pValue Flag indicating whether the sheet navigation block should be generated or not

Return Value

HTML

writeAllSheets()

Write all sheets (resets sheetIndex to NULL).

string generateHTMLHeader(bool $pIncludeStyles = false)

Generate HTML header.

Parameters

bool $pIncludeStyles Include styles?

Return Value

string

Exceptions

Exception

string generateSheetData()

Generate sheet data.

Return Value

string

Exceptions

Exception

string generateNavigation()

Generate sheet tabs.

Return Value

string

Exceptions

Exception

string generateStyles(bool $generateSurroundingHTML = true)

Generate CSS styles.

Parameters

bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>)

Return Value

string

Exceptions

Exception

array buildCSS(bool $generateSurroundingHTML = true)

Build CSS styles.

Parameters

bool $generateSurroundingHTML Generate surrounding HTML style? (html { })

Return Value

array

Exceptions

Exception

generateHTMLFooter()

Generate HTML footer.

string getImagesRoot()

Get images root.

Return Value

string

HTML setImagesRoot(string $pValue)

Set images root.

Parameters

string $pValue

Return Value

HTML

bool getEmbedImages()

Get embed images.

Return Value

bool

HTML setEmbedImages(bool $pValue)

Set embed images.

Parameters

bool $pValue

Return Value

HTML

bool getUseInlineCss()

Get use inline CSS?

Return Value

bool

HTML setUseInlineCss(bool $pValue)

Set use inline CSS?

Parameters

bool $pValue

Return Value

HTML

string formatColor(string $pValue, string $pFormat)

Add color to formatted string as inline style.

Parameters

string $pValue Plain formatted value without color
string $pFormat Format code

Return Value

string

string getFont()

Get Font.

Return Value

string

Pdf setFont(string $fontName)

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

Parameters

string $fontName

Return Value

Pdf

int getPaperSize()

Get Paper Size.

Return Value

int

Pdf setPaperSize(string $pValue)

Set Paper Size.

Parameters

string $pValue Paper size see PageSetup::PAPERSIZE_*

Return Value

Pdf

string getOrientation()

Get Orientation.

Return Value

string

Pdf setOrientation(string $pValue)

Set Orientation.

Parameters

string $pValue Page orientation see PageSetup::ORIENTATION_*

Return Value

Pdf

string getTempDir()

Get temporary storage directory.

Return Value

string

Pdf setTempDir(string $pValue)

Set temporary storage directory.

Parameters

string $pValue Temporary storage directory

Return Value

Pdf

Exceptions

Exception when directory does not exist

protected resource prepareForSave(string $pFilename)

Save Spreadsheet to PDF file, pre-save.

Parameters

string $pFilename Name of the file to save as

Return Value

resource

Exceptions

Exception

protected restoreStateAfterSave(resource $fileHandle)

Save PhpSpreadsheet to PDF file, post-save.

Parameters

resource $fileHandle