From: vincent@cubedesigners.com Date: Tue, 2 Mar 2010 18:52:42 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7326bfe4259d75e9dd64293b16c3f03483bf8977;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.conversion.session.php b/inc/ws/Controlleur/class.ws.conversion.session.php index 269ded484..a62c8d7c3 100644 --- a/inc/ws/Controlleur/class.ws.conversion.session.php +++ b/inc/ws/Controlleur/class.ws.conversion.session.php @@ -38,12 +38,7 @@ class wsConversionSession { $dao = new wsDAODocument($core->con); $this->documents = $dao->selectInList($this->documentsId); - $this->totalPages = 0; - - foreach($this->documents as $doc) { - $this->totalPages += $doc->getPagesNumber(); - } - $this->totalDoc = count($this->documents); + $this->updateCountPages(); $inited = true; } @@ -60,6 +55,9 @@ class wsConversionSession { $this->currentDoc = $doc; $this->serialize(); $this->currentDoc->globalOperations(); + $this->currentDoc = $dao->updateFromObject($this->currentDoc); + $this->updateCountPages(); + for($i = 1;$i <= $doc->generalInfos['pages'];$i++) { $this->currentDocPage = $i; $this->totalDocPage = $doc->generalInfos['pages']; @@ -77,6 +75,15 @@ class wsConversionSession { $this->setProgress(100); } + public function updateCountPages() + { + $this->totalPages = 0; + foreach($this->documents as $doc) { + $this->totalPages += $doc->generalInfos['pages']; + } + $this->totalDoc = count($this->documents); + } + public function getProgress() { return array("progress" => $this->progress, diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 9b5a26daa..34b2e6230 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -46,6 +46,11 @@ class wsDocument extends cubeMetier { const BARBARE_GS = 5; protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5); + // Number section styles + protected static + $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal', + 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low', + 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low'); public function init() { @@ -68,14 +73,21 @@ class wsDocument extends cubeMetier { $this->uncropDocument(); } - public function getInfos() + public function getInfos($in = null, $force = false) { - $pdfinfo = $this->getBasicInfos(); - $pdftk = $this->getAdvancedInfos(); + if(is_null($in)){ + $in=$this->in; + } - $this->parseInfos($pdfinfo . $pdftk); + $fwstk = new cubeCommandLine('fwstk'); + $fwstk->setPath(CONVERTER_PATH); + $fwstk->setArg('--input ' . $in); + $fwstk->setArg('--infos'); + $fwstk->execute(); + $this->addToLog($fwstk); + $this->parseInfos($fwstk->output); - file_put_contents($this->infos, $pdfinfo . $pdftk); + file_put_contents($this->infos, $fwstk->output); $this->findCutDisposition(); } @@ -153,37 +165,6 @@ class wsDocument extends cubeMetier { } } - public function getBasicInfos() - { - if (is_null($this->_basicInfos)) { - $pdfinfo = new cubeCommandLine('pdfinfo', null, false); - $pdfinfo->setPath(CONVERTER_PATH); - $pdfinfo->setArg('-box'); - $pdfinfo->setArg('f', 1); - $pdfinfo->setArg('l', 10000); - $pdfinfo->setArg(null, $this->in); - $pdfinfo->execute(); - $this->addToLog($pdfinfo); - - $this->_basicInfos = $pdfinfo->output; - } - return $this->_basicInfos; - } - - public function getAdvancedInfos() - { - if (is_null($this->_advancedInfos)) { - $pdftk = new cubeCommandLine('pdftk', null, true); - $pdftk->setPath(CONVERTER_PATH); - $pdftk->setArg(null, $this->in); - $pdftk->setArg(null, 'dump_data'); - $pdftk->execute(); - $this->addToLog($pdftk); - $this->_advancedInfos = $pdftk->output; - } - return $this->_advancedInfos; - } - public function parseInfos($data) { // This function get general infos (pages sizes, boxes, number sections and @@ -191,11 +172,7 @@ class wsDocument extends cubeMetier { // Init arrays $this->generalInfos = array(); $this->bookmarks = array(); - $this->numberSections = array(); - // Number section styles - $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal', - 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low', - 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low'); + $this->numberSections = ''; $res['size'] = array(0, 0); $lines = explode("\n", $data); @@ -219,15 +196,8 @@ class wsDocument extends cubeMetier { } elseif ($k == 'BookmarkPageNumber') { $this->bookmarks[$bookmark_id]['page'] = $v; $bookmark_id++; - } elseif ($k == 'PageLabelNewIndex') { - $section = array('startAt' => $v, 'style' => 'decimal', 'firstNumber' => 1, 'prefix' => ''); - } else if ($k == 'PageLabelStart') { - $section['firstNumber'] = $v; - } elseif ($k == 'PageLabelPrefix') { - $section['prefix'] = $v; - } else if ($k == 'PageLabelNumStyle') { - $section['style'] = $numberStyles[$v]; - $this->numberSections[] = $section; + } elseif ($k == 'NumberSections') { + $this->numberSection = $v; } } @@ -236,14 +206,15 @@ class wsDocument extends cubeMetier { public function getPagesNumber() { - $this->parseInfos($this->getBasicInfos()); + $this->getInfos(); return $this->generalInfos['pages']; } public function globalOperations() { $this->getInfos(); - $this->Crop(); + $this->CropAndCut(); + $this->getInfos($this->cropped, true); $this->getLinks(); $this->getTexts(); } @@ -263,7 +234,13 @@ class wsDocument extends cubeMetier { public function cutDocument($mode) { - + $fwstk = new cubeCommandLine('fwstk'); + $fwstk->setPath(CONVERTER_PATH); + $fwstk->setArg('--input ' . $this->in); + $fwstk->setArg('--cut ' . $mode); + $fwstk->setArg('--output ' . $this->cropped); + $fwstk->execute(); + $this->addToLog($fwstk); } public function trimDocument() @@ -430,7 +407,7 @@ class wsDocument extends cubeMetier { protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null) { if (is_null($in)) { - $in = $this->crop; + $in = $this->cropped; } $antialiasing = $antialiasing?'yes':'no'; $resolution = round($resolution); @@ -473,6 +450,11 @@ class wsDocument extends cubeMetier { } } + protected function isCropped() + { + return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut; + } + public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0) { if ($maxObjects <= 1) { @@ -480,7 +462,7 @@ class wsDocument extends cubeMetier { } // Pour les fichiers croppés, on utilise la méthode flatten qui ne prends // pas en compte les objets hors de la box - if ($this->crop) { + if ($this->isCropped()) { $method = max($method, self::FLATTEN); } @@ -694,7 +676,7 @@ disablelinks Disable links. { $fwstk = new cubeCommandLine('fwstk'); $fwstk->setPath(CONVERTER_PATH); - $fwstk->setArg('--input ' . $this->in); + $fwstk->setArg('--input ' . $this->cropped); $fwstk->setArg('--extractLinks ' . $this->out . 'p%d.csv'); $fwstk->execute(); $this->addToLog($fwstk);