2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 namespace PMA\libraries
;
14 * PDF export base class providing basic configuration.
18 class PDF
extends TCPDF
26 const PMA_PDF_FONT
= 'DejaVuSans';
29 * Constructs PDF and configures standard parameters.
31 * @param string $orientation page orientation
32 * @param string $unit unit
33 * @param string $format the format used for pages
34 * @param boolean $unicode true means that the input text is unicode
35 * @param string $encoding charset encoding; default is UTF-8.
36 * @param boolean $diskcache if true reduce the RAM memory usage by caching
37 * temporary data on filesystem (slower).
38 * @param boolean $pdfa If TRUE set the document to PDF/A mode.
42 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
43 $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa=false
46 $orientation, $unit, $format, $unicode,
47 $encoding, $diskcache, $pdfa
49 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
50 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
51 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
52 $this->SetFont(PDF
::PMA_PDF_FONT
, '', 14);
53 $this->setFooterFont(array(PDF
::PMA_PDF_FONT
, '', 14));
57 * This function must be named "Footer" to work with the TCPDF library
61 public function Footer()
63 // Check if footer for this page already exists
64 if (!isset($this->footerset
[$this->page
])) {
66 $this->SetFont(PDF
::PMA_PDF_FONT
, '', 14);
69 __('Page number:') . ' '
70 . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(),
73 $this->Cell(0, 6, Util
::localisedDate(), 0, 1, 'R');
77 $this->footerset
[$this->page
] = 1;
82 * Function to set alias which will be expanded on page rendering.
84 * @param string $name name of the alias
85 * @param string $value value of the alias
89 public function SetAlias($name, $value)
91 $name = TCPDF_FONTS
::UTF8ToUTF16BE(
92 $name, false, true, $this->CurrentFont
94 $this->Alias
[$name] = TCPDF_FONTS
::UTF8ToUTF16BE(
95 $value, false, true, $this->CurrentFont
100 * Improved with alias expanding.
104 public function _putpages()
106 if (count($this->Alias
) > 0) {
107 $nbPages = count($this->pages
);
108 for ($n = 1; $n <= $nbPages; $n++
) {
109 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
116 * Displays an error message
118 * @param string $error_message the error message
122 public function Error($error_message = '')
125 __('Error while creating PDF:') . ' ' . $error_message
131 * Sends file as a download to user.
133 * @param string $filename file name
137 public function Download($filename)
139 $pdfData = $this->getPDFData();
140 Response
::getInstance()->disable();