2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 if (! defined('PHPMYADMIN')) {
12 require_once TCPDF_INC
;
17 define('PMA_PDF_FONT', 'DejaVuSans');
20 * PDF export base class providing basic configuration.
24 class PMA_PDF
extends TCPDF
30 * Constructs PDF and configures standard parameters.
32 * @param string $orientation page orientation
33 * @param string $unit unit
34 * @param mixed $format the format used for pages
35 * @param boolean $unicode true means that the input text is unicode
36 * @param string $encoding charset encoding; default is UTF-8.
37 * @param boolean $diskcache if true reduce the RAM memory usage by caching
38 * temporary data on filesystem (slower).
43 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
44 $unicode = true, $encoding = 'UTF-8', $diskcache = false
46 parent
::__construct();
47 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
48 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
49 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
50 $this->SetFont(PMA_PDF_FONT
, '', 14);
51 $this->setFooterFont(array(PMA_PDF_FONT
, '', 14));
55 * This function must be named "Footer" to work with the TCPDF library
61 // Check if footer for this page already exists
62 if (!isset($this->footerset
[$this->page
])) {
64 $this->SetFont(PMA_PDF_FONT
, '', 14);
65 $this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
66 $this->Cell(0, 6, PMA_Util
::localisedDate(), 0, 1, 'R');
70 $this->footerset
[$this->page
] = 1;
75 * Function to test an empty string (was in tcpdf < 6.0)
77 * @param string $str to test
81 public function empty_string($str) {
82 return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
86 * Function to set alias which will be expanded on page rendering.
88 * @param string $name name of the alias
89 * @param string $value value of the alias
93 function SetAlias($name, $value)
95 $this->Alias
[$this->UTF8ToUTF16BE($name)] = $this->UTF8ToUTF16BE($value);
99 * Improved with alias expading.
105 if (count($this->Alias
) > 0) {
106 $nb = count($this->pages
);
107 for ($n = 1;$n <= $nb;$n++
) {
108 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
115 * Displays an error message
117 * @param string $error_message the error mesage
121 function Error($error_message = '')
124 __('Error while creating PDF:') . ' ' . $error_message
130 * Sends file as a download to user.
132 * @param string $filename file name
136 function Download($filename)
138 $pdfData = $this->getPDFData();
139 PMA_Response
::getInstance()->disable();
140 PMA_downloadHeader($filename, 'application/pdf', strlen($pdfData));