]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 Mar 2010 14:56:14 +0000 (14:56 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 2 Mar 2010 14:56:14 +0000 (14:56 +0000)
inc/ws/Controlleur/class.ws.conversion.session.php
inc/ws/Metier/class.ws.document.php

index d15820cb8f9818c5f6b6d06ac4d3c3c4188916fb..269ded484c93c7bfcb7df466e371e95f1262c537 100644 (file)
@@ -64,7 +64,7 @@ class wsConversionSession {
                                $this->currentDocPage = $i;\r
                                $this->totalDocPage = $doc->generalInfos['pages'];\r
                                $this->setProgress(($this->processedPages / $this->totalPages) * 100);\r
-                               $this->currentDoc->processOnePage($i);\r
+                               $this->currentDoc->processOnePage($i, false);\r
                                $this->processedPages++;\r
                        }\r
                        $doc = $dao->updateFromObject($doc);\r
index 72fad252713dc96844bbac619fd806085d63bdc1..9b5a26daabf602eecaba60e59873ea44b2b144ff 100644 (file)
@@ -20,8 +20,12 @@ class wsDocument extends cubeMetier {
        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
@@ -72,16 +76,13 @@ class wsDocument extends cubeMetier {
                $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
@@ -106,15 +107,16 @@ class wsDocument extends cubeMetier {
                $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
@@ -128,24 +130,26 @@ class wsDocument extends cubeMetier {
 \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
@@ -244,13 +248,22 @@ class wsDocument extends cubeMetier {
                $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
@@ -275,12 +288,14 @@ class wsDocument extends cubeMetier {
                $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
@@ -393,7 +408,7 @@ class wsDocument extends cubeMetier {
                $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