aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/3rdparty/libraries/tcpdf/tcpdf.php10
-rw-r--r--inc/poche/WallabagEBooks.class.php38
2 files changed, 38 insertions, 10 deletions
diff --git a/inc/3rdparty/libraries/tcpdf/tcpdf.php b/inc/3rdparty/libraries/tcpdf/tcpdf.php
index 78694a0e..70c1747a 100644
--- a/inc/3rdparty/libraries/tcpdf/tcpdf.php
+++ b/inc/3rdparty/libraries/tcpdf/tcpdf.php
@@ -2927,11 +2927,17 @@ class TCPDF {
2927 public function Error($msg) { 2927 public function Error($msg) {
2928 // unset all class variables 2928 // unset all class variables
2929 $this->_destroy(true); 2929 $this->_destroy(true);
2930 throw new Exception('TCPDF ERROR: '.$msg);
2931 /*
2932
2933 I had problems with the constants for some reason, so here we force
2934
2935 $this->_destroy(true);
2930 if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) { 2936 if (defined('K_TCPDF_THROW_EXCEPTION_ERROR') AND !K_TCPDF_THROW_EXCEPTION_ERROR) {
2931 die('<strong>TCPDF ERROR: </strong>'.$msg); 2937 die('<strong>TCPDF ERROR: </strong>'.$msg);
2932 } else { 2938 } else {
2933 throw new Exception('TCPDF ERROR: '.$msg); 2939 throw new Exception('TCPDF ERROR: '.$msg);
2934 } 2940 }*/
2935 } 2941 }
2936 2942
2937 /** 2943 /**
@@ -6915,7 +6921,7 @@ class TCPDF {
6915 $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k; 6921 $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k;
6916 $imsize = array($pw, $ph); 6922 $imsize = array($pw, $ph);
6917 } else { 6923 } else {
6918 $this->Error('[Image] Unable to get the size of the image: '.$file); 6924 $this->Error('[Image] Unable to fetch image: '.$file);
6919 } 6925 }
6920 } 6926 }
6921 // file hash 6927 // file hash
diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php
index bc40990b..d31939a1 100644
--- a/inc/poche/WallabagEBooks.class.php
+++ b/inc/poche/WallabagEBooks.class.php
@@ -33,7 +33,7 @@ class WallabagEBooks
33 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId()); 33 $entry = $this->wallabag->store->retrieveOneById($entryID, $this->wallabag->user->getId());
34 $this->entries = array($entry); 34 $this->entries = array($entry);
35 $this->bookTitle = $entry['title']; 35 $this->bookTitle = $entry['title'];
36 $this->bookFileName = substr($this->bookTitle, 0, 200); 36 $this->bookFileName = str_replace('/', '_', substr($this->bookTitle, 0, 200));
37 $this->author = preg_replace('#^w{3}.#', '', Tools::getdomain($entry["url"])); # if only one article, set author to domain name (we strip the eventual www part) 37 $this->author = preg_replace('#^w{3}.#', '', Tools::getdomain($entry["url"])); # if only one article, set author to domain name (we strip the eventual www part)
38 Tools::logm('Producing ebook from article ' . $this->bookTitle); 38 Tools::logm('Producing ebook from article ' . $this->bookTitle);
39 break; 39 break;
@@ -81,6 +81,9 @@ class WallabagEpub extends WallabagEBooks
81 public function produceEpub() 81 public function produceEpub()
82 { 82 {
83 Tools::logm('Starting to produce ePub 3 file'); 83 Tools::logm('Starting to produce ePub 3 file');
84
85 try {
86
84 $content_start = 87 $content_start =
85 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 88 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
86 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" 89 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
@@ -155,6 +158,11 @@ class WallabagEpub extends WallabagEBooks
155 $book->finalize(); 158 $book->finalize();
156 $zipData = $book->sendBook($this->bookFileName); 159 $zipData = $book->sendBook($this->bookFileName);
157 Tools::logm('Ebook produced'); 160 Tools::logm('Ebook produced');
161 }
162 catch (Exception $e) {
163 Tools::logm('PHPePub has encountered an error : '.$e->getMessage());
164 $this->wallabag->messages->add('e', $e->getMessage());
165 }
158 } 166 }
159} 167}
160 168
@@ -167,7 +175,7 @@ class WallabagMobi extends WallabagEBooks
167 175
168 public function produceMobi() 176 public function produceMobi()
169 { 177 {
170 178 try {
171 Tools::logm('Starting to produce Mobi file'); 179 Tools::logm('Starting to produce Mobi file');
172 $mobi = new MOBI(); 180 $mobi = new MOBI();
173 $content = new MOBIFile(); 181 $content = new MOBIFile();
@@ -197,6 +205,11 @@ class WallabagMobi extends WallabagEBooks
197 // we offer file to download 205 // we offer file to download
198 $mobi->download($this->bookFileName.'.mobi'); 206 $mobi->download($this->bookFileName.'.mobi');
199 Tools::logm('Mobi file produced'); 207 Tools::logm('Mobi file produced');
208 }
209 catch (Exception $e) {
210 Tools::logm('PHPMobi has encountered an error : '.$e->getMessage());
211 $this->wallabag->messages->add('e', $e->getMessage());
212 }
200 } 213 }
201} 214}
202 215
@@ -206,15 +219,16 @@ class WallabagPDF extends WallabagEbooks
206 { 219 {
207 220
208 Tools::logm('Starting to produce PDF file'); 221 Tools::logm('Starting to produce PDF file');
209 222 @define ('K_TCPDF_THROW_EXCEPTION_ERROR', TRUE);
223 try {
210 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 224 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
211 225
212 Tools::logm('Filling metadata for PDF...'); 226 Tools::logm('Filling metadata for PDF...');
213 $pdf->SetCreator(PDF_CREATOR); 227 $pdf->SetCreator(PDF_CREATOR);
214 $pdf->SetAuthor(''); 228 $pdf->SetAuthor('wallabag');
215 $pdf->SetTitle($this->bookTitle); 229 $pdf->SetTitle($this->bookTitle);
216 $pdf->SetSubject('TCPDF Tutorial'); 230 $pdf->SetSubject('Articles via wallabag');
217 $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); 231 $pdf->SetKeywords('wallabag');
218 232
219 Tools::logm('Adding introduction...'); 233 Tools::logm('Adding introduction...');
220 $pdf->AddPage(); 234 $pdf->AddPage();
@@ -229,18 +243,26 @@ class WallabagPDF extends WallabagEbooks
229 $i = 1; 243 $i = 1;
230 Tools::logm('Adding actual content...'); 244 Tools::logm('Adding actual content...');
231 foreach ($this->entries as $item) { 245 foreach ($this->entries as $item) {
246 $tags = $this->wallabag->store->retrieveTagsByEntry($entry['id']);
247 foreach ($tags as $tag) {
248 $pdf->SetKeywords($tag['value']);
249 }
232 $pdf->AddPage(); 250 $pdf->AddPage();
233 $html = '<h1>' . $item['title'] . '</h1>'; 251 $html = '<h1>' . $item['title'] . '</h1>';
234 $html .= $item['content']; 252 $html .= $item['content'];
235 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); 253 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
236 $i = $i+1;
237 } 254 }
238 255
239 // set image scale factor 256 // set image scale factor
240 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 257 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
241 258
242 259
243 $pdf->Output($this->bookFileName . '.pdf', 'FD'); 260 $pdf->Output($this->bookFileName . '.pdf', 'FD');
261 }
262 catch (Exception $e) {
263 Tools::logm('TCPDF has encountered an error : '.$e->getMessage());
264 $this->wallabag->messages->add('e', $e->getMessage());
265 }
244 266
245 } 267 }
246} 268}