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).
39 * @param boolean $pdfa If TRUE set the document to PDF/A mode.
44 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
45 $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa=false
48 $orientation, $unit, $format, $unicode,
49 $encoding, $diskcache, $pdfa
51 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
52 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
53 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
54 $this->SetFont(PMA_PDF_FONT
, '', 14);
55 $this->setFooterFont(array(PMA_PDF_FONT
, '', 14));
59 * This function must be named "Footer" to work with the TCPDF library
65 // Check if footer for this page already exists
66 if (!isset($this->footerset
[$this->page
])) {
68 $this->SetFont(PMA_PDF_FONT
, '', 14);
71 __('Page number:') . ' '
72 . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(),
75 $this->Cell(0, 6, PMA_Util
::localisedDate(), 0, 1, 'R');
79 $this->footerset
[$this->page
] = 1;
84 * Function to set alias which will be expanded on page rendering.
86 * @param string $name name of the alias
87 * @param string $value value of the alias
91 function SetAlias($name, $value)
93 $name = TCPDF_FONTS
::UTF8ToUTF16BE(
94 $name, false, true, $this->CurrentFont
96 $this->Alias
[$name] = TCPDF_FONTS
::UTF8ToUTF16BE(
97 $value, false, true, $this->CurrentFont
102 * Improved with alias expading.
108 if (count($this->Alias
) > 0) {
109 $nb = count($this->pages
);
110 for ($n = 1;$n <= $nb;$n++
) {
111 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
118 * Displays an error message
120 * @param string $error_message the error mesage
124 function Error($error_message = '')
127 __('Error while creating PDF:') . ' ' . $error_message
133 * Sends file as a download to user.
135 * @param string $filename file name
139 function Download($filename)
141 $pdfData = $this->getPDFData();
142 PMA_Response
::getInstance()->disable();
143 PMA_downloadHeader($filename, 'application/pdf', strlen($pdfData));