return;
}
+ global $core;
+ $dao = new wsDAOBook($core->con);
+ $book = $dao->selectById($this->args['id']);
+
$bookmarks = json_decode(base64_decode($this->args['bookmarks']), true);
$files = array();
foreach ($bookmarks as $b) {
}
// Paths init
$baseDocument = $this->getPDFComplexBaseDocument($book);
- fb($baseDocument);
+ fb($baseDocument, '!!');
if (!file_exists($baseDocument)) {
+ fb('not exists');
return;
}
$destDir = WS_CACHE . '/exportpdf/' . $book->cid;
mkdir($destDir, 0777, true);
}
$fname = md5(implode(',%ù', $range)) . '.pdf';
+ fb($fname);
$destFile = $destDir . '/' . $fname;
$destURL = '/fluidbook/cache/exportpdf/' . $book->cid . '/' . $fname;
+ fb($destFile);
+
// If result exists, don't make the pdf again
if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) {
-
+ fb('already exists');
} else {
// Prepare the command line
$l = array('A="' . $baseDocument . '"', 'cat');
$pdftk->setPath(CONVERTER_PATH);
$pdftk->setManualArg($args);
$pdftk->execute();
+ fb($pdftk->commande);
+ fb($pdftk->output);
}
return array('url' => $destURL, 'file' => $destFile);
}
public function getPDFComplexBaseDocument($book) {
+ global $core;
$normal = WS_BOOKS . '/pdf/' . $book->book_id . '/original.pdf';
+ if (!file_exists($normal)) {
+ $daoBook = new wsDAOBook($core->con);
+ $pages = $daoBook->getPagesOfBook($book->book_id);
+ $daoBook->compilePDF($book, $pages);
+ }
if ($book->parametres->pdfReplace != '' && file_exists($normal)) {
$this->xml->addChild('normal', $normal);
return $normal;
}
- return WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;
+ $res = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;
+ if (!file_exists($res)) {
+ return $normal;
+ }
+ return $normal;
}
public function e() {