const BARBARE_GS = 5;\r
\r
protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
+ // Number section styles\r
+ protected static\r
+ $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
+ 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
+ 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
\r
public function init()\r
{\r
$this->uncropDocument();\r
}\r
\r
- public function getInfos()\r
+ public function getInfos($in = null, $force = false)\r
{\r
- $pdfinfo = $this->getBasicInfos();\r
- $pdftk = $this->getAdvancedInfos();\r
+ if(is_null($in)){\r
+ $in=$this->in;\r
+ }\r
\r
- $this->parseInfos($pdfinfo . $pdftk);\r
+ $fwstk = new cubeCommandLine('fwstk');\r
+ $fwstk->setPath(CONVERTER_PATH);\r
+ $fwstk->setArg('--input ' . $in);\r
+ $fwstk->setArg('--infos');\r
+ $fwstk->execute();\r
+ $this->addToLog($fwstk);\r
+ $this->parseInfos($fwstk->output);\r
\r
- file_put_contents($this->infos, $pdfinfo . $pdftk);\r
+ file_put_contents($this->infos, $fwstk->output);\r
$this->findCutDisposition();\r
}\r
\r
}\r
}\r
\r
- public function getBasicInfos()\r
- {\r
- if (is_null($this->_basicInfos)) {\r
- $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
- $pdfinfo->setPath(CONVERTER_PATH);\r
- $pdfinfo->setArg('-box');\r
- $pdfinfo->setArg('f', 1);\r
- $pdfinfo->setArg('l', 10000);\r
- $pdfinfo->setArg(null, $this->in);\r
- $pdfinfo->execute();\r
- $this->addToLog($pdfinfo);\r
-\r
- $this->_basicInfos = $pdfinfo->output;\r
- }\r
- return $this->_basicInfos;\r
- }\r
-\r
- public function getAdvancedInfos()\r
- {\r
- if (is_null($this->_advancedInfos)) {\r
- $pdftk = new cubeCommandLine('pdftk', null, true);\r
- $pdftk->setPath(CONVERTER_PATH);\r
- $pdftk->setArg(null, $this->in);\r
- $pdftk->setArg(null, 'dump_data');\r
- $pdftk->execute();\r
- $this->addToLog($pdftk);\r
- $this->_advancedInfos = $pdftk->output;\r
- }\r
- return $this->_advancedInfos;\r
- }\r
-\r
public function parseInfos($data)\r
{\r
// This function get general infos (pages sizes, boxes, number sections and\r
// Init arrays\r
$this->generalInfos = array();\r
$this->bookmarks = array();\r
- $this->numberSections = array();\r
- // Number section styles\r
- $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
- 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
- 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
+ $this->numberSections = '';\r
\r
$res['size'] = array(0, 0);\r
$lines = explode("\n", $data);\r
} elseif ($k == 'BookmarkPageNumber') {\r
$this->bookmarks[$bookmark_id]['page'] = $v;\r
$bookmark_id++;\r
- } elseif ($k == 'PageLabelNewIndex') {\r
- $section = array('startAt' => $v, 'style' => 'decimal', 'firstNumber' => 1, 'prefix' => '');\r
- } else if ($k == 'PageLabelStart') {\r
- $section['firstNumber'] = $v;\r
- } elseif ($k == 'PageLabelPrefix') {\r
- $section['prefix'] = $v;\r
- } else if ($k == 'PageLabelNumStyle') {\r
- $section['style'] = $numberStyles[$v];\r
- $this->numberSections[] = $section;\r
+ } elseif ($k == 'NumberSections') {\r
+ $this->numberSection = $v;\r
}\r
}\r
\r
\r
public function getPagesNumber()\r
{\r
- $this->parseInfos($this->getBasicInfos());\r
+ $this->getInfos();\r
return $this->generalInfos['pages'];\r
}\r
\r
public function globalOperations()\r
{\r
$this->getInfos();\r
- $this->Crop();\r
+ $this->CropAndCut();\r
+ $this->getInfos($this->cropped, true);\r
$this->getLinks();\r
$this->getTexts();\r
}\r
\r
public function cutDocument($mode)\r
{\r
-\r
+ $fwstk = new cubeCommandLine('fwstk');\r
+ $fwstk->setPath(CONVERTER_PATH);\r
+ $fwstk->setArg('--input ' . $this->in);\r
+ $fwstk->setArg('--cut ' . $mode);\r
+ $fwstk->setArg('--output ' . $this->cropped);\r
+ $fwstk->execute();\r
+ $this->addToLog($fwstk);\r
}\r
\r
public function trimDocument()\r
protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)\r
{\r
if (is_null($in)) {\r
- $in = $this->crop;\r
+ $in = $this->cropped;\r
}\r
$antialiasing = $antialiasing?'yes':'no';\r
$resolution = round($resolution);\r
}\r
}\r
\r
+ protected function isCropped()\r
+ {\r
+ return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut;\r
+ }\r
+\r
public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0)\r
{\r
if ($maxObjects <= 1) {\r
}\r
// Pour les fichiers croppés, on utilise la méthode flatten qui ne prends\r
// pas en compte les objets hors de la box\r
- if ($this->crop) {\r
+ if ($this->isCropped()) {\r
$method = max($method, self::FLATTEN);\r
}\r
\r
{\r
$fwstk = new cubeCommandLine('fwstk');\r
$fwstk->setPath(CONVERTER_PATH);\r
- $fwstk->setArg('--input ' . $this->in);\r
+ $fwstk->setArg('--input ' . $this->cropped);\r
$fwstk->setArg('--extractLinks ' . $this->out . 'p%d.csv');\r
$fwstk->execute();\r
$this->addToLog($fwstk);\r