From 824f8c45edb20e27221e92805b0090f1768a2756 Mon Sep 17 00:00:00 2001 From: tcit Date: Sat, 27 Sep 2014 19:34:17 +0200 Subject: changed mpdf with tcpdf --- inc/poche/WallabagEBooks.class.php | 56 ++++++++++++++++---------------------- inc/poche/global.inc.php | 3 +- 2 files changed, 26 insertions(+), 33 deletions(-) (limited to 'inc/poche') diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php index 80aa7e43..d77fe0d8 100644 --- a/inc/poche/WallabagEBooks.class.php +++ b/inc/poche/WallabagEBooks.class.php @@ -262,53 +262,45 @@ class WallabagPDF extends WallabagEbooks { public function producePDF() { - $mpdf = new mPDF('c'); Tools::logm('Starting to produce PDF file'); - Tools::logm('Filling metadata for PDF...'); - - # headers - $mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/{nb}|Produced with wallabag'); - $mpdf->SetFooter('{PAGENO}'); + $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); - # intro - $html = '

' . $this->bookTitle . '

-

' . _('Produced by wallabag with mPDF') . '

+ Tools::logm('Filling metadata for PDF...'); + $pdf->SetCreator(PDF_CREATOR); + $pdf->SetAuthor(''); + $pdf->SetTitle($this->bookTitle); + $pdf->SetSubject('TCPDF Tutorial'); + $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); + + Tools::logm('Adding introduction...'); + $pdf->AddPage(); + $intro = '

' . $this->bookTitle . '

+

' . _('Produced by wallabag with tcpdf') . '

'. _('Please open an issue if you have trouble with the display of this E-Book on your device.') . '

'; - $html .= ''; - $i = 1; + + $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true); + + $i = 1; Tools::logm('Adding actual content...'); foreach ($this->entries as $item) { - $html .= '

' . $item['title'] . '

'; - $html .= ''; + $pdf->AddPage(); + $html = '

' . $item['title'] . '

'; $html .= $item['content']; - $html .= ''; + $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); $i = $i+1; } - - $mpdf->WriteHTML($html); - # remove characters that make mpdf bug - $char_in = array('/', '.', ',', ':', '|'); - $pdfExportName = preg_replace('/\s+/', '-', str_replace($char_in, '-', $this->bookFileName . '.pdf')); # maybe someone can make a proper regex of this ? + // set image scale factor + $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - # index - $html = '

Index

- - '; + + - $mpdf->WriteHTML($html); - - $mpdf->Output('cache/' . $pdfExportName); - - header('Content-Disposition: attachment; filename="' . $pdfExportName . '"'); + $pdf->Output($this->bookFileName, 'I'); - header('Content-Transfer-Encoding: base64'); - header('Content-Type: application/pdf'); - echo file_get_contents('cache/' . $pdfExportName); - Tools::logm('PDF file produced'); } } \ No newline at end of file diff --git a/inc/poche/global.inc.php b/inc/poche/global.inc.php index 182f721d..728528f8 100755 --- a/inc/poche/global.inc.php +++ b/inc/poche/global.inc.php @@ -45,7 +45,8 @@ require_once INCLUDES . '/3rdparty/libraries/PHPePub/EPubChapterSplitter.php'; require_once INCLUDES . '/3rdparty/libraries/MOBIClass/MOBI.php'; # pdf library -require_once INCLUDES . '/3rdparty/libraries/mpdf/mpdf.php'; +#require_once INCLUDES . '/3rdparty/libraries/mpdf/mpdf.php'; +require_once INCLUDES . '/3rdparty/libraries/tcpdf/tcpdf.php'; # system configuration; database credentials et caetera require_once INCLUDES . '/poche/config.inc.php'; -- cgit v1.2.3