]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Mar 2012 13:49:26 +0000 (13:49 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Mar 2012 13:49:26 +0000 (13:49 +0000)
inc/ws/Metier/class.ws.document.php

index fd1713f8a144c1ace8e6df764a7b300e94da470d..4cb48bdebedffd855fb68c81bd80591d27e3f138 100644 (file)
@@ -40,6 +40,7 @@ class wsDocument extends cubeMetier {
        protected $infos;\r
        protected $cropped;\r
        protected $uncropped;\r
+       protected $rgb;\r
 \r
        const NORMAL = 0;\r
        const FLATTEN = 1;\r
@@ -47,9 +48,7 @@ class wsDocument extends cubeMetier {
        const BITMAP = 3;\r
        const BARBARE_PNM = 4;\r
        const BARBARE_GS = 5;\r
-\r
        const MAX = 5;\r
-\r
        const PNM_FILL = 2;\r
 \r
        protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
@@ -74,6 +73,7 @@ class wsDocument extends cubeMetier {
                        mkdir($this->html, 0755);\r
                }\r
                $this->cropped = $this->out . 'crop.pdf';\r
+               $this->rgb = $this->out . 'rgb.pdf';\r
                $this->uncropped = $this->out . 'uncrop.pdf';\r
                $this->pages_log_pointers = array();\r
 \r
@@ -201,7 +201,7 @@ class wsDocument extends cubeMetier {
                $this->addToLog('Detect Spreads : Manual cut ' . $this->manualcut . ' ; Auto cut : ' . $this->autocut);\r
        }\r
 \r
-       public static function compareSizes($x, $y, $tolerance=0.9) {\r
+       public static function compareSizes($x, $y, $tolerance = 0.9) {\r
                return cubeMath::compare($x[0], $y[0], $tolerance) && cubeMath::compare($x[1], $y[1], $tolerance);\r
        }\r
 \r
@@ -264,10 +264,43 @@ class wsDocument extends cubeMetier {
                if ($this->CropAndCut()) {\r
                        $this->getInfos($this->cropped, true);\r
                }\r
+               $this->performColorTransformations();\r
                $this->extractFonts();\r
                $this->getLinksAndTexts();\r
        }\r
 \r
+       public function performColorTransformations() {\r
+               $out = $this->out . '/rgb.pdf';\r
+\r
+               $gs = new cubeCommandLine('gs', null, true);\r
+               $gs->setPath(CONVERTER_PATH);\r
+               $gs->setEnv('GS_FONTPATH', FONT_PATH);\r
+               $gs->setArg('-dBATCH');\r
+               $gs->setArg('-dNOPAUSE');\r
+               $gs->setArg('-dNOPROMPT');\r
+               // Device\r
+               $gs->setArg('-sDEVICE=pdfwrite');\r
+               // \r
+               $gs->setArg('-dDownsampleColorImages=false');\r
+               $gs->setArg('-dDownsampleGrayImages=false');\r
+               $gs->setArg('-dDownsampleMonoImages=false');\r
+               // Dispotion & colors\r
+               $gs->setArg('-dConvertCMYKImagesToRGB=true');\r
+               $gs->setArg('-dAutoRotatePages=/None');\r
+               $gs->setArg('-dUseCropBox');\r
+               $gs->setArg('-dShowAnnots=false');\r
+               // Performances\r
+               $gs->setArg('-dNumRenderingThreads=4');\r
+               // Page range\r
+               // Files\r
+               $gs->setArg('-sOutputFile=' . $out);\r
+\r
+               $gs->setArg(null, $this->cropped);\r
+               $gs->execute();\r
+               \r
+               $this->addToLog($gs);\r
+       }\r
+\r
        public function CropAndCut() {\r
                if (!$this->isCropped()) {\r
                        copy($this->in, $this->cropped);\r
@@ -509,7 +542,7 @@ class wsDocument extends cubeMetier {
                return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut;\r
        }\r
 \r
-       public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null, $version=null) {\r
+       public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null, $version = null) {\r
                $conversionSettings = $this->conversionInfos->pages[$page];\r
                if (is_null($storeAllChars)) {\r
                        $storeAllChars = true;\r
@@ -626,7 +659,7 @@ class wsDocument extends cubeMetier {
         * @param integer $method\r
         * @return\r
         */\r
-       protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p', $version='stable') {\r
+       protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p', $version = 'stable') {\r
                /*\r
                  -h , --help                    Print short help message and exit\r
                  -V , --version                 Print version info and exit\r
@@ -750,7 +783,11 @@ class wsDocument extends cubeMetier {
                        $pdf2swf->setArg('set jpegquality', $quality);\r
                        $pdf2swf->setArg('set disablelinks');\r
                        $pdf2swf->setArg('set dots');\r
-                       $pdf2swf->setArg(null, $this->cropped);\r
+                       if(file_exists($this->rgb)){\r
+                       $pdf2swf->setArg(null, $this->rgb);\r
+                       }else{\r
+                               $pdf2swf->setArg(null, $this->cropped);\r
+                       }\r
                        $pdf2swf->setArg('output', $this->out . $prefix . '%.swf');\r
                        $pdf2swf->execute();\r
 \r
@@ -833,7 +870,7 @@ class wsDocument extends cubeMetier {
        }\r
 \r
        public function resetLog() {\r
-               file_put_contents($this->log . '/commons.log', '');\r
+               unlink($this->log . '/commons.log.gz');\r
        }\r
 \r
        public function addToLog($cl, $output = true, $page = null) {\r