public function getZoomAttributes()
{
- return [
+ $pdf = $this->compiler->book->parametres->downloadPortionPDF;
+ if ($pdf !== '') {
+ $pdf = $this->compiler->wdir . '/' . $this->compiler->book->parametres->downloadPortionPDF;
+ }
+
+ $res = [
'id' => $this->id,
'page' => $this->page,
'maxzoom' => $this->compiler->book->parametres->downloadPortionZoom,
'width' => round($this->width),
'height' => round($this->height),
'x' => round($this->left),
- 'y' => round($this->top)
+ 'y' => round($this->top),
+ 'pdf' => $pdf,
];
+ return $res;
}
-
public function getAdditionnalContent()
{
$file = $this->to;
//error_log("--- Book Width: $bookwidth ---");
- $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page']);
- $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+ if (!isset($attributes['pdf']) || !$attributes['pdf']) {
+ $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page']);
+ $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+ $extractPage = 1;
+ } else {
+ $pdfpath = $attributes['pdf'];
+ $extractPage = $attributes['page'];
+ }
$left = CubeIT_Files::tempnam();
$leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
- 1,
+ $extractPage,
array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
$left, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
if (($x + $w) > $bookwidth) {
- $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);
- $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+ if (!isset($attributes['pdf']) || !$attributes['pdf']) {
+ $p = wsDAOBook::getDocumentPage($compiler->book_id, $attributes['page'] + 1);
+ $pdfpath = wsDocument::getDir($p['document_id']) . '/pdf/p' . $p['document_page'] . '.pdf';
+ $extractPage = 1;
+ } else {
+ $pdfpath = $attributes['pdf'];
+ $extractPage = $attributes['page'] + 1;
+ }
+
$diff = ($w + $x) - $bookwidth;
$right = CubeIT_Files::tempnam();
$rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
- 1,
+ $extractPage,
array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
$right, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');