protected $bookmarks;\r
protected $numberSections;\r
protected $links;\r
- protected $crop;\r
-\r
+ // Crop & cut\r
+ protected $autocrop;\r
+ protected $manualcrop;\r
+ protected $autocut;\r
+ protected $manualcut;\r
+ // Files\r
protected $out;\r
protected $in;\r
protected $uncompressed;\r
$this->parseInfos($pdfinfo . $pdftk);\r
\r
file_put_contents($this->infos, $pdfinfo . $pdftk);\r
- $this->crop = $this->findCutDisposition();\r
+ $this->findCutDisposition();\r
}\r
\r
public function findCutDisposition()\r
{\r
- $spreads = $this->detectSpreads();\r
- if ($spreads) {\r
- return $spreads;\r
- }\r
- return $this->detectPageDifferences();\r
+ $this->detectSpreads();\r
+ $this->detectPageDifferences();\r
}\r
\r
protected function detectPageDifferences()\r
$heights = array_unique($heights);\r
$widths = array_unique($widths);\r
if (count($heights) == 1 && count($widths) == 1) {\r
- return 'TTRIM';\r
+ $this->autocrop = 'trim';\r
+ $this->manualcrop = false;\r
} else {\r
- return 'TMANUEL';\r
+ $this->autocrop = false;\r
+ $this->manualcrop = true;\r
}\r
}\r
\r
protected function detectSpreads()\r
{\r
- $spread = false;\r
// Détection des spreads\r
foreach($this->generalInfos['page'] as $page => $infos) {\r
if ($page == 1) {\r
\r
if ($first == $last && $last == $second) {\r
$ratio = $first[0] / $first[1];\r
+ $this->autocut = false;\r
if ($ratio <= 1) {\r
- return false;\r
+ $this->manualcut = false;\r
} elseif ($ratio >= 6) {\r
- return 'CSL8';\r
+ $this->manualcut = 'L8';\r
} elseif ($ratio >= 3) {\r
- return 'CSL4';\r
+ $this->manualcut = 'L4';\r
} elseif ($ratio >= 2) {\r
- return 'CSL3';\r
+ $this->manualcut = 'L3';\r
} else {\r
- return 'CS-14-23';\r
+ $this->manualcut = '14-23';\r
}\r
+ return;\r
}\r
-\r
+ $this->manualcut = false;\r
if ($first == $last && round($first[0] * 2) == round($second[0])) {\r
- return 'C1-23-4';\r
+ $this->autocut = '1-23-4';\r
}\r
if (round($first[0] * 2) == round($second[0]) && $last == $second) {\r
- return 'C1-23';\r
+ $this->autocut = '1-23';\r
}\r
}\r
\r
$this->getTexts();\r
}\r
\r
- public function Crop()\r
+ public function CropAndCut()\r
{\r
- if ($this->crop == 'TTRIM') {\r
+ if ($this->autocrop == 'trim') {\r
$this->trimDocument();\r
} else {\r
copy($this->in, $this->cropped);\r
}\r
+\r
+ if ($this->autocut) {\r
+ $this->cutDocument($this->autocut);\r
+ }\r
+ }\r
+\r
+ public function cutDocument($mode)\r
+ {\r
+\r
}\r
\r
public function trimDocument()\r
$this->addToLog($fwstk);\r
}\r
\r
- public function processOnePage($page)\r
+ public function processOnePage($page, $force = true)\r
{\r
- $this->makeMiniShot($page);\r
$this->makeRealShot($page);\r
- $this->makeSWFFiles($page, 150, 90, true, 1800, 1);\r
- $this->makeAS3($page);\r
+ if ($force || $this) {\r
+ $this->makeMiniShot($page);\r
+ $this->makeSWFFiles($page, 150, 90, true, 1800, 1);\r
+ $this->makeAS3($page);\r
+ }\r
}\r
\r
public function processAllPages()\r
$gs->setArg('-dUseCIEColor');\r
$gs->setArg('-dAutoRotatePages=/None');\r
// Resolution & Quality\r
- $gs->setArg('-r' . $resolution);\r
+ $gs->setArg('-r' . round($resolution));\r
$gs->setArg('-dJPEGQ=' . $quality);\r
// Antialias\r
$gs->setArg('-dDOINTERPOLATE');\r