aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
authortcit <tcit@tcit.fr>2014-09-27 19:34:17 +0200
committertcit <tcit@tcit.fr>2014-09-27 19:34:17 +0200
commit824f8c45edb20e27221e92805b0090f1768a2756 (patch)
tree8563a41cc27619347c851b3a06285bf2474b69dd /inc/poche
parentd4690a8fa18c27c6d98c1c76ac1d1d2c35a1ebbb (diff)
downloadwallabag-824f8c45edb20e27221e92805b0090f1768a2756.tar.gz
wallabag-824f8c45edb20e27221e92805b0090f1768a2756.tar.zst
wallabag-824f8c45edb20e27221e92805b0090f1768a2756.zip
changed mpdf with tcpdf
Diffstat (limited to 'inc/poche')
-rw-r--r--inc/poche/WallabagEBooks.class.php56
-rwxr-xr-xinc/poche/global.inc.php3
2 files changed, 26 insertions, 33 deletions
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
262{ 262{
263 public function producePDF() 263 public function producePDF()
264 { 264 {
265 $mpdf = new mPDF('c');
266 265
267 Tools::logm('Starting to produce PDF file'); 266 Tools::logm('Starting to produce PDF file');
268 267
269 Tools::logm('Filling metadata for PDF...'); 268 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
270
271 # headers
272 $mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/{nb}|Produced with wallabag');
273 $mpdf->SetFooter('{PAGENO}');
274 269
275 # intro 270 Tools::logm('Filling metadata for PDF...');
276 $html = '<h1>' . $this->bookTitle . '<bookmark content="Cover" /></h1><div style="text-align:center;" > 271 $pdf->SetCreator(PDF_CREATOR);
277 <p>' . _('Produced by wallabag with mPDF') . '</p> 272 $pdf->SetAuthor('');
273 $pdf->SetTitle($this->bookTitle);
274 $pdf->SetSubject('TCPDF Tutorial');
275 $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
276
277 Tools::logm('Adding introduction...');
278 $pdf->AddPage();
279 $intro = '<h1>' . $this->bookTitle . '</h1><div style="text-align:center;" >
280 <p>' . _('Produced by wallabag with tcpdf') . '</p>
278 <p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p> 281 <p>'. _('Please open <a href="https://github.com/wallabag/wallabag/issues" >an issue</a> if you have trouble with the display of this E-Book on your device.') . '</p>
279 <img src="themes/baggy/img/apple-touch-icon-152.png" /></div>'; 282 <img src="themes/baggy/img/apple-touch-icon-152.png" /></div>';
280 $html .= '<pagebreak type="next-odd" />';
281 $i = 1;
282 283
284
285 $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
286
287 $i = 1;
283 Tools::logm('Adding actual content...'); 288 Tools::logm('Adding actual content...');
284 foreach ($this->entries as $item) { 289 foreach ($this->entries as $item) {
285 $html .= '<h1>' . $item['title'] . '<bookmark content="' . $item['title'] . '" /></h1>'; 290 $pdf->AddPage();
286 $html .= '<indexentry content="'. $item['title'] .'" />'; 291 $html = '<h1>' . $item['title'] . '</h1>';
287 $html .= $item['content']; 292 $html .= $item['content'];
288 $html .= '<pagebreak type="next-odd" />'; 293 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
289 $i = $i+1; 294 $i = $i+1;
290 } 295 }
291
292 $mpdf->WriteHTML($html);
293 296
294 # remove characters that make mpdf bug 297 // set image scale factor
295 $char_in = array('/', '.', ',', ':', '|'); 298 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
296 $pdfExportName = preg_replace('/\s+/', '-', str_replace($char_in, '-', $this->bookFileName . '.pdf')); # maybe someone can make a proper regex of this ?
297 299
298 # index 300
299 $html = '<h2>Index<bookmark content="Index" /></h2> 301
300 <indexinsert cols="2" offset="5" usedivletters="on" div-font-size="15" gap="5" font="Trebuchet" div-font="sans-serif" links="on" />
301 ';
302 302
303 $mpdf->WriteHTML($html); 303 $pdf->Output($this->bookFileName, 'I');
304
305 $mpdf->Output('cache/' . $pdfExportName);
306
307 header('Content-Disposition: attachment; filename="' . $pdfExportName . '"');
308 304
309 header('Content-Transfer-Encoding: base64');
310 header('Content-Type: application/pdf');
311 echo file_get_contents('cache/' . $pdfExportName);
312 Tools::logm('PDF file produced');
313 } 305 }
314} \ No newline at end of file 306} \ 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';
45require_once INCLUDES . '/3rdparty/libraries/MOBIClass/MOBI.php'; 45require_once INCLUDES . '/3rdparty/libraries/MOBIClass/MOBI.php';
46 46
47# pdf library 47# pdf library
48require_once INCLUDES . '/3rdparty/libraries/mpdf/mpdf.php'; 48#require_once INCLUDES . '/3rdparty/libraries/mpdf/mpdf.php';
49require_once INCLUDES . '/3rdparty/libraries/tcpdf/tcpdf.php';
49 50
50# system configuration; database credentials et caetera 51# system configuration; database credentials et caetera
51require_once INCLUDES . '/poche/config.inc.php'; 52require_once INCLUDES . '/poche/config.inc.php';