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 string $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).
39 * @param boolean $pdfa If TRUE set the document to PDF/A mode.
43 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
44 $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa=false
47 $orientation, $unit, $format, $unicode,
48 $encoding, $diskcache, $pdfa
50 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
51 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
52 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
53 $this->SetFont(PMA_PDF_FONT
, '', 14);
54 $this->setFooterFont(array(PMA_PDF_FONT
, '', 14));
58 * This function must be named "Footer" to work with the TCPDF library
62 public function Footer()
64 // Check if footer for this page already exists
65 if (!isset($this->footerset
[$this->page
])) {
67 $this->SetFont(PMA_PDF_FONT
, '', 14);
70 __('Page number:') . ' '
71 . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(),
74 $this->Cell(0, 6, PMA_Util
::localisedDate(), 0, 1, 'R');
78 $this->footerset
[$this->page
] = 1;
83 * Function to set alias which will be expanded on page rendering.
85 * @param string $name name of the alias
86 * @param string $value value of the alias
90 public function SetAlias($name, $value)
92 $name = TCPDF_FONTS
::UTF8ToUTF16BE(
93 $name, false, true, $this->CurrentFont
95 $this->Alias
[$name] = TCPDF_FONTS
::UTF8ToUTF16BE(
96 $value, false, true, $this->CurrentFont
101 * Improved with alias expanding.
105 public function _putpages()
107 if (count($this->Alias
) > 0) {
108 $nbPages = count($this->pages
);
109 for ($n = 1; $n <= $nbPages; $n++
) {
110 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
117 * Displays an error message
119 * @param string $error_message the error message
123 public function Error($error_message = '')
126 __('Error while creating PDF:') . ' ' . $error_message
132 * Sends file as a download to user.
134 * @param string $filename file name
138 public function Download($filename)
140 $pdfData = $this->getPDFData();
141 PMA_Response
::getInstance()->disable();
145 /*overload*/mb_strlen($pdfData)