$this->themeSettings->usePageEdges = false;
}
+
public function initConfig()
{
if (!$this->scormVariant) {
$this->pageLabels[$label] = $page;
}
- public function getResolutions()
- {
- return self::getBookResolutions($this->getFluidbook());
- }
-
-
- public static function getBookResolutions($book)
- {
- $maxRes = min(self::MAX_RES, $book->settings['maxResolution']);
- $res = [];
- if ($maxRes == self::MAX_RES) {
- $res = [150, self::MAX_RES];
- } else if ($maxRes <= 150) {
- $res = [$maxRes];
- }
- return $res;
- }
-
public function getCssScale()
{
return $this->cssScale;
namespace App\Fluidbook\Compiler;
+use App\Models\FluidbookPublication;
use Cubist\Util\CommandLine;
use Cubist\Util\Files\Files;
use Cubist\Util\Graphics\Image;
trait Images
{
+ public function getResolutions()
+ {
+ return self::getBookResolutions($this->getFluidbook());
+ }
+
+
+ /**
+ * @param $book FluidbookPublication
+ * @return array
+ */
+ public static function getBookResolutions($book)
+ {
+ $maxRes = min(self::MAX_RES, $book->getSettings()->maxResolution);
+ $res = [];
+ if ($maxRes == self::MAX_RES) {
+ $res = [150, self::MAX_RES];
+ } else if ($maxRes <= 150) {
+ $res = [$maxRes];
+ }
+ return $res;
+ }
+
protected function writeImages()
{
$compositionCached = $this->compositionCached();
public function fixPDF()
{
- return Farm::fixPDF($this->getPDFSource('original'), $this->getPDFSource('fixed'));
+ return Farm::fixPDF($this->getPDFSource('original'), $this->getPDFSource('fixed', false));
}
public function splitPDF()
return $this->_getTextBasePath($mode, $ignoreSeparators) . $prefix . $type . $page . '.txt';
}
- public function getPDFSource($type = 'crop'): string
+ public function getPDFSource($type = 'crop', $checkIfExists = true): string
{
- return $this->path() . $type . '.pdf';
+ $res = $this->path() . $type . '.pdf';
+ if ($checkIfExists && !file_exists($res)) {
+ if ($type === 'crop') {
+ $this->lnCrop();
+ } else if ($type === 'fixed') {
+ $this->fixPDF();
+ }
+ }
+
+ return $res;
}
public function cutDocument($mode)
{
- Farm::cutPDF($this->getPDFSource('fixed'), $mode, $this->getPDFSource());
+ Farm::cutPDF($this->getPDFSource('fixed'), $mode, $this->getPDFSource('crop', false));
}
public function trimDocument()
{
- Farm::trimPDF($this->getPDFSource('fixed'), $this->getPDFSource());
+ Farm::trimPDF($this->getPDFSource('fixed'), $this->getPDFSource('crop', false));
}
public function lnCrop()
{
- link($this->getPDFSource('fixed'), $this->getPDFSource());
+ link($this->getPDFSource('fixed'), $this->getPDFSource('crop', false));
}
protected function isCropped()
{
if (null === $this->_settingsData) {
$this->_settingsData = $this->getPageData();
- $this->_settingsData->setOffsetPrefix('settings.');
}
return $this->_settingsData;
}