function tcpdf_get_instance in TCPDF 8
Same name and namespace in other branches
- 7 tcpdf.module \tcpdf_get_instance()
Gets an instance of TCPDFDrupal. Always use this function to get a fresh instance of the class.
Parameters
array $params: Associative array of parameters for the TCPDF constructor. Check out the documentation of TCPDF.
array $class: Associative array that tells tcpdf_get_instance to use a custom class instead of TCPDFDrupal. The class should be the sibling of TCPDFDrupal. Note that this functionality is not mature, and may be changed in later releases. 'class' => Name of the class. 'filetype' => Container file's type. 'filename' => Container file's name. 'module' => Module where the container file is.
array $config: Associative array that tells tcdf_get_instance to use a different config file. 'filetype' => Config file's type. 'filename' => Config file's name. 'module' => Module where the config file is.
Return value
mixed FALSE\TCPDFDrupal object
1 call to tcpdf_get_instance()
- TcpPdfExampleController::generateSimplePdf in tcpdf_example/
src/ Controller/ TcpPdfExampleController.php - Generates a pdf file using TCPDF module.
File
- ./
tcpdf.module, line 30 - TCPDF module provides an API to use TCPDF in Drupal environment.
Code
function tcpdf_get_instance($params = array(), $class = array(), $config = array()) {
$default_params = array(
'orientation' => 'P',
'unit' => 'mm',
'format' => 'A4',
'unicode' => TRUE,
'encoding' => 'UTF-8',
'diskcache' => FALSE,
'pdfa' => FALSE,
);
$params = array_merge($default_params, $params);
if (!isset($class['class'])) {
$class = array(
'class' => 'Drupal\\tcpdf\\TCPDFDrupal',
);
}
if (!isset($config['filename'])) {
$config = array(
'filetype' => 'inc',
'filename' => 'tcpdf.config',
'module' => 'tcpdf',
);
}
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
}
module_load_include($config['filetype'], $config['module'], $config['filename']);
return new $class['class']($params['orientation'], $params['unit'], $params['format'], $params['unicode'], $params['encoding'], $params['diskcache'], $params['pdfa']);
}