aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/WallabagEBooks.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/WallabagEBooks.class.php')
-rw-r--r--inc/poche/WallabagEBooks.class.php56
1 files changed, 24 insertions, 32 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