Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
dataformat_pdf\writer Class Reference

pdf data format writer More...

Inheritance diagram for dataformat_pdf\writer:
core\dataformat\base

Public Member Functions

 __construct ()
 writer constructor.
 
 close_output ()
 Write the end of the file.
 
 close_output_to_file ()
 Write data to disk.
 
 close_sheet ($columns)
 Write the end of the sheet containing the data.
 
 get_extension ()
 Get the file extension.
 
 send_http_headers ()
 Output file headers to initialise the download of the file.
 
 set_filename ($filename)
 Set download filename base.
 
 set_filepath (string $filepath)
 Set file path when writing to file.
 
 set_sheettitle ($title)
 Set the title of the worksheet inside a spreadsheet.
 
 start_output ()
 Write the start of the file.
 
 start_output_to_file ()
 Start output to file, note that the actual writing of the file is done in {.
 
 start_sheet ($columns)
 Write the start of the sheet we will be adding data to.
 
 supports_html ()
 Method to define whether the dataformat supports export of HTML.
 
 write_record ($record, $rownum)
 Write a single record.
 

Public Attributes

 $extension = ".pdf"
 
 $mimetype = "application/pdf"
 

Protected Member Functions

 export_html_image_source (\stored_file $file)
 When exporting images, we need to return their Base64 encoded content.
 
 format_record ($record)
 Apply formatting to the cells of a given record.
 
 replace_pluginfile_images (?string $content)
 We need to locate all img tags within a given cell that match pluginfile URL's.
 

Protected Attributes

string[] $columns
 Title of columns in the current sheet.
 
float $colwidth
 Each column's width in the current sheet.
 
$filename $filename = ''
 
string $filepath = ''
 The location to store the output content.
 
pdf $pdf
 The pdf object that is used to generate the pdf file.
 

Detailed Description

pdf data format writer

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ close_output()

dataformat_pdf\writer::close_output ( )

Write the end of the file.

Reimplemented from core\dataformat\base.

◆ close_output_to_file()

dataformat_pdf\writer::close_output_to_file ( )

Write data to disk.

Return values
bool

Reimplemented from core\dataformat\base.

◆ close_sheet()

core\dataformat\base::close_sheet ( $columns)
inherited

Write the end of the sheet containing the data.

Parameters
array$columns

Reimplemented in dataformat_html\writer, and dataformat_json\writer.

◆ export_html_image_source()

dataformat_pdf\writer::export_html_image_source ( \stored_file $file)
protected

When exporting images, we need to return their Base64 encoded content.

Otherwise TCPDF will create a HTTP request for them, which will lead to the login page (i.e. not the image it expects) and throw an exception

Note: ideally we would copy the file to a temp location and return it's path, but a bug in TCPDF currently prevents that

Parameters
stored_file$file
Return values
string|null

Reimplemented from core\dataformat\base.

◆ format_record()

core\dataformat\base::format_record ( $record)
protectedinherited

Apply formatting to the cells of a given record.

Parameters
array | stdClass$record
Return values
array

◆ get_extension()

core\dataformat\base::get_extension ( )
inherited

Get the file extension.

Return values
stringfile extension

◆ replace_pluginfile_images()

core\dataformat\base::replace_pluginfile_images ( ?string $content)
protectedinherited

We need to locate all img tags within a given cell that match pluginfile URL's.

Partly so the exported file will show the image without requiring the user is logged in; and also to prevent some of the dataformats requesting the file themselves, which is likely to fail due to them not having an active session

Parameters
string | null$content
Return values
string

◆ send_http_headers()

dataformat_pdf\writer::send_http_headers ( )

Output file headers to initialise the download of the file.

Reimplemented from core\dataformat\base.

◆ set_filename()

core\dataformat\base::set_filename ( $filename)
inherited

Set download filename base.

Parameters
string$filename

◆ set_filepath()

core\dataformat\base::set_filepath ( string $filepath)
inherited

Set file path when writing to file.

Parameters
string$filepath
Exceptions
coding_exception

◆ set_sheettitle()

core\dataformat\base::set_sheettitle ( $title)
inherited

Set the title of the worksheet inside a spreadsheet.

For some formats this will be ignored.

Parameters
string$title

Reimplemented in core\dataformat\spout_base, dataformat_excel\writer, and dataformat_ods\writer.

◆ start_output()

dataformat_pdf\writer::start_output ( )

Write the start of the file.

Reimplemented from core\dataformat\base.

◆ start_output_to_file()

dataformat_pdf\writer::start_output_to_file ( )

Start output to file, note that the actual writing of the file is done in {.

See also
close_output_to_file()}

Reimplemented from core\dataformat\base.

◆ start_sheet()

dataformat_pdf\writer::start_sheet ( $columns)

Write the start of the sheet we will be adding data to.

Parameters
array$columns

Reimplemented from core\dataformat\base.

◆ supports_html()

dataformat_pdf\writer::supports_html ( )

Method to define whether the dataformat supports export of HTML.

Return values
bool

Reimplemented from core\dataformat\base.

◆ write_record()

dataformat_pdf\writer::write_record ( $record,
$rownum )

Write a single record.

Parameters
array$record
int$rownum

Reimplemented from core\dataformat\base.


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