$range[$k] = $r->pages;
}
- if (!count($range)) {
- return;
- }
+ $range = array_unique($range);
+ sort($range);
+
+
// Paths init
$baseDocument = $this->getPDFComplexBaseDocument($book);
- fb($baseDocument, '!!');
+
if (!file_exists($baseDocument)) {
- fb('not exists');
return;
}
+
+ if (!count($range)) {
+ return;
+ }
+
+
$destDir = WS_CACHE . '/exportpdf/' . $book->cid;
if (!file_exists($destDir)) {
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');
- foreach ($range as $page) {
- if ($page < 1 || $page > $book->parametres->pages) {
- continue;
+ if ($range[0] == 1 && count($range) == $book->parametres->pages && $range[$book->parametres->pages - 1] == $book->parametres->pages) {
+ `cp $baseDocument $destFile`;
+ } else {
+
+ // Prepare the command line
+ $l = array('A="' . $baseDocument . '"', 'cat');
+ foreach ($range as $page) {
+ if ($page < 1 || $page > $book->parametres->pages) {
+ continue;
+ }
+ $l[] = 'A' . $page;
}
- $l[] = 'A' . $page;
+ $l[] = 'output';
+ $l[] = $destFile;
+
+ $args = implode(' ', $l);
+ // Execute the command line
+ $pdftk = new cubeCommandLine('pdftk');
+ $pdftk->setPath(CONVERTER_PATH);
+ $pdftk->setManualArg($args);
+ $pdftk->execute();
}
- $l[] = 'output';
- $l[] = $destFile;
-
- $args = implode(' ', $l);
- // Execute the command line
- $pdftk = new cubeCommandLine('pdftk');
- $pdftk->setPath(CONVERTER_PATH);
- $pdftk->setManualArg($args);
- $pdftk->execute();
- fb($pdftk->commande);
- fb($pdftk->output);
}
return array('url' => $destURL, 'file' => $destFile);
public function exportpdf($print = false) {
global $core;
+ set_time_limit(0);
+
$dao = new wsDAOBook($core->con);
if (isset($this->args['cid'])) {
$book = $dao->selectByCid($this->args['cid']);