2 /* vim: set expandtab sw=4 ts=4 sts=4: */
7 require_once './libraries/tcpdf/tcpdf.php';
12 define('PMA_PDF_FONT', 'DejaVuSans');
15 * PDF export base class providing basic configuration.
17 class PMA_PDF
extends TCPDF
22 public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false)
24 parent
::__construct();
25 $this->SetAuthor('phpMyAdmin ' . PMA_VERSION
);
26 $this->AliasNbPages();
27 $this->AddFont('DejaVuSans', '', 'dejavusans.php');
28 $this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
29 $this->SetFont(PMA_PDF_FONT
, '', 14);
30 $this->setFooterFont(array(PMA_PDF_FONT
, '', 14));
34 * This function must be named "Footer" to work with the TCPDF library
38 // Check if footer for this page already exists
39 if (!isset($this->footerset
[$this->page
])) {
41 $this->SetFont(PMA_PDF_FONT
, '', 14);
42 $this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
43 $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');
47 $this->footerset
[$this->page
] = 1;
52 * Function to set alias which will be expanded on page rendering.
54 function SetAlias($name, $value)
56 $this->Alias
[$this->UTF8ToUTF16BE($name)] = $this->UTF8ToUTF16BE($value);
60 * Improved with alias expading.
64 if (count($this->Alias
) > 0) {
65 $nb = count($this->pages
);
66 for ($n = 1;$n <= $nb;$n++
) {
67 $this->pages
[$n] = strtr($this->pages
[$n], $this->Alias
);
74 * Displays an error message
76 * @param string $error_message the error mesage
78 function Error($error_message = '')
80 include('./libraries/header.inc.php');
81 PMA_Message
::error(__('Error while creating PDF:') . ' ' . $error_message)->display();
82 include('./libraries/footer.inc.php');
86 * Sends file as a download to user.
88 function Download($filename)
90 $pdfData = $this->getPDFData();
91 PMA_download_header($filename, 'application/pdf', strlen($pdfData));