Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
pdflib.php - Moodle PDF library More...
Classes | |
class | |
Wrapper class that extends TCPDF (lib/tcpdf/tcpdf.php). More... | |
Functions | |
tcpdf_init_k_font_path () | |
Init K_PATH_FONTS and PDF_FONT_NAME_MAIN constant. More... | |
Variables | |
const | K_BLANK_IMAGE K_PATH_IMAGES . 'pix/spacer.gif' |
blank image | |
const | K_CELL_HEIGHT_RATIO 1.25 |
height of cell repect font height | |
const | K_PATH_CACHE $CFG->cachedir . '/tcpdf/' |
cache directory for temporary files (full path) | |
const | K_PATH_IMAGES $CFG->dirroot . '/' |
images directory | |
const | K_PATH_MAIN $CFG->dirroot.'/lib/tcpdf/' |
tcpdf installation path | |
const | K_PATH_URL $CFG->wwwroot . '/lib/tcpdf/' |
URL path to tcpdf installation folder. | |
const | K_SMALL_RATIO 2/3 |
reduction factor for small font | |
const | K_TCPDF_EXTERNAL_CONFIG (!defined('PDF_DEFAULT_FONT')) 1 |
tell tcpdf it is configured here instead of in its own config file | |
const | K_TCPDF_THROW_EXCEPTION_ERROR true |
Throw exceptions from errors so they can be caught and recovered from. | |
pdflib.php - Moodle PDF library
We currently use the TCPDF library by Nicola Asuni.
The default location for fonts that are included with TCPDF is lib/tcpdf/fonts/. If PDF_CUSTOM_FONT_PATH exists, this directory will be used instead of lib/tcpdf/fonts/, the default location is $CFG->dataroot.'/fonts/'.
You should always copy all fonts from lib/tcpdf/fonts/ to your PDF_CUSTOM_FONT_PATH and then add extra fonts. Alternatively you may download all TCPDF fonts from http://www.tcpdf.org/download.php and extract them to PDF_CUSTOM_FONT_PATH directory.
You can specify your own default font family in config.php by defining PDF_DEFAULT_FONT constant there.
If you want to add True Type fonts such as "Arial Unicode MS", you need to create a simple script and then execute it, it should add new file to your fonts directory: <?php require('config.php'); require_once($CFG->libdir . '/pdflib.php'); TCPDF_FONTS::addTTFfont('/full_path_to/ARIALUNI.TTF', 'TrueTypeUnicode');
This script will convert the TTF file to format compatible with TCPDF.
Please note you need to have appropriate license to use the font files on your server!
Example usage: $doc = new pdf; $doc->setPrintHeader(false); $doc->setPrintFooter(false); $doc->AddPage(); $doc->Write(5, 'Hello World!'); $doc->Output();