2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 use PhpMyAdmin\Message
;
12 use PhpMyAdmin\Response
;
18 * PDF export base class providing basic configuration.
22 class Pdf
extends TCPDF
30 const PMA_PDF_FONT
= 'DejaVuSans';
33 * Constructs PDF and configures standard parameters.
35 * @param string $orientation page orientation
36 * @param string $unit unit
37 * @param string $format the format used for pages
38 * @param boolean $unicode true means that the input text is unicode
39 * @param string $encoding charset encoding; default is UTF-8.
40 * @param boolean $diskcache if true reduce the RAM memory usage by caching
41 * temporary data on filesystem (slower).
42 * @param boolean $pdfa If TRUE set the document to PDF/A mode.
46 public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
47 $unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa=false
50 $orientation, $unit, $format, $unicode,
51 $encoding, $diskcache, $pdfa
53 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
54 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
55 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
56 $this->SetFont(Pdf
::PMA_PDF_FONT
, '', 14);
57 $this->setFooterFont(array(Pdf
::PMA_PDF_FONT
, '', 14));
61 * This function must be named "Footer" to work with the TCPDF library
65 // @codingStandardsIgnoreLine
66 public function Footer()
68 // Check if footer for this page already exists
69 if (!isset($this->footerset
[$this->page
])) {
71 $this->SetFont(Pdf
::PMA_PDF_FONT
, '', 14);
74 __('Page number:') . ' '
75 . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(),
78 $this->Cell(0, 6, Util
::localisedDate(), 0, 1, 'R');
82 $this->footerset
[$this->page
] = 1;
87 * Function to set alias which will be expanded on page rendering.
89 * @param string $name name of the alias
90 * @param string $value value of the alias
94 public function setAlias($name, $value)
96 $name = TCPDF_FONTS
::UTF8ToUTF16BE(
97 $name, false, true, $this->CurrentFont
99 $this->Alias
[$name] = TCPDF_FONTS
::UTF8ToUTF16BE(
100 $value, false, true, $this->CurrentFont
105 * Improved with alias expanding.
109 public function _putpages()
111 if (count($this->Alias
) > 0) {
112 $nbPages = count($this->pages
);
113 for ($n = 1; $n <= $nbPages; $n++
) {
114 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
121 * Displays an error message
123 * @param string $error_message the error message
127 // @codingStandardsIgnoreLine
128 public function Error($error_message = '')
131 __('Error while creating PDF:') . ' ' . $error_message
137 * Sends file as a download to user.
139 * @param string $filename file name
143 public function download($filename)
145 $pdfData = $this->getPDFData();
146 Response
::getInstance()->disable();
147 Core
::downloadHeader(