Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / libraries / PDF.class.php
blob3f4f2f1c6589fa38000d841018030de5bfc464f2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * TCPDF wrapper class.
5 */
7 require_once './libraries/tcpdf/tcpdf.php';
9 /**
10 * PDF font to use.
12 define('PMA_PDF_FONT', 'DejaVuSans');
14 /**
15 * PDF export base class providing basic configuration.
17 class PMA_PDF extends TCPDF
19 var $footerset;
20 var $Alias = array();
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));
33 /**
34 * This function must be named "Footer" to work with the TCPDF library
36 function Footer()
38 // Check if footer for this page already exists
39 if (!isset($this->footerset[$this->page])) {
40 $this->SetY(-15);
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');
44 $this->SetY(20);
46 // set footerset
47 $this->footerset[$this->page] = 1;
51 /**
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);
59 /**
60 * Improved with alias expading.
62 function _putpages()
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);
70 parent::_putpages();
73 /**
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');
85 /**
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));
92 echo $pdfData;