]> _ Git - cubeextranet.git/commitdiff
fix #2389 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 3 Dec 2018 17:23:26 +0000 (17:23 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 3 Dec 2018 17:23:26 +0000 (17:23 +0000)
inc/ws/Metier/class.ws.document.php
inc/ws/Util/class.ws.tools.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 75b9d96d89eeb8770e4b800e675df1932855e4b2..7ec94035e95897c2fa01c65b08bcd291da5e3ef8 100644 (file)
@@ -83,6 +83,13 @@ class wsDocument extends cubeMetier
                }
        }
 
+       public function getCroppedPDF(){
+               if(!file_exists($this->cropped)){
+                       return $this->in;
+               }
+               return $this->cropped;
+       }
+
        public function copyOriginalFromUpload($tmp_file)
        {
                move_uploaded_file($tmp_file, $this->in);
@@ -315,7 +322,7 @@ class wsDocument extends cubeMetier
                mkdir($this->out . '/pdf');
                $pdftk = new cubeCommandLine('pdftk');
                $pdftk->setPath(CONVERTER_PATH);
-               $pdftk->setArg(null, $this->cropped);
+               $pdftk->setArg(null, $this->getCroppedPDF());
                $pdftk->setArg(null, 'burst');
                $pdftk->setArg(null, 'output');
                $pdftk->setArg(null, $this->out . 'pdf/p%d.pdf');
@@ -393,7 +400,7 @@ class wsDocument extends cubeMetier
        {
                $fwstk = new cubeCommandLine('fwstk.sh');
                $fwstk->setPath(CONVERTER_PATH);
-               $fwstk->setArg('--input ' . $this->cropped);
+               $fwstk->setArg('--input ' . $this->getCroppedPDF());
                $fwstk->setArg('--extractLinks ' . $this->out . 'p%d.csv');
                $fwstk->setArg('--threads 1');
                $fwstk->execute();
@@ -404,7 +411,7 @@ class wsDocument extends cubeMetier
        {
                $fwstk = new cubeCommandLine('fwstk.sh');
                $fwstk->setPath(CONVERTER_PATH);
-               $fwstk->setArg('--input ' . $this->cropped);
+               $fwstk->setArg('--input ' . $this->getCroppedPDF());
                $fwstk->setArg('--layout ' . $this->html . 'p%d.fby');
                $fwstk->setArg('--cmaps ' . $this->html);
                $fwstk->setArg('--fonts' . $this->out . 'fonts/web/');
@@ -447,7 +454,7 @@ class wsDocument extends cubeMetier
        {
                $error = false;
                if (is_null($in)) {
-                       $in = $this->cropped;
+                       $in =  $this->getCroppedPDF();
                }
                // Delete all old files
                $res = $this->out . $prefix . $page . '.jpg';
@@ -477,7 +484,7 @@ class wsDocument extends cubeMetier
        protected function makeShotGS($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)
        {
                if (is_null($in)) {
-                       $in = $this->cropped;
+                       $in =  $this->getCroppedPDF();
                }
                // Fabrication des thumbanails avec ghostscript
                $gs = new cubeCommandLine('gs', null, true);
@@ -515,7 +522,7 @@ class wsDocument extends cubeMetier
        protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null, $texts = true)
        {
                if (is_null($in)) {
-                       $in = $this->cropped;
+                       $in = $this->getCroppedPDF();
                }
 
                $tmp = cubeFiles::tempnam();
@@ -653,10 +660,7 @@ class wsDocument extends cubeMetier
        public function makeSVGFile($page)
        {
                $svgFile = $this->out . '/html/fp' . $page . '.svg';
-               $source = $this->cropped;
-               if (!file_exists($this->cropped)) {
-                       $source = $this->in;
-               }
+               $source =  $this->getCroppedPDF();
 
                $pdftocairo = new cubeCommandLine('pdftocairo');
                $pdftocairo->setPath(CONVERTER_PATH);
index 548fb5a240a1ed5544270ade55cec43d2ecff232..dfb2dbca2058b6385a1da078b35886e4fd41d11e 100644 (file)
@@ -182,7 +182,6 @@ class wsTools
                                        self::$_r = $resolution;
                                        $osvg = preg_replace_callback('|\<image([^>]*)\>|', 'wsTools::optimizeRaster', $svg);
                                        $ofname = sprintf($optimized, '-' . $resolution);
-                                       echo $ofname . "\n";
                                        file_put_contents($ofname, $osvg);
                                }
                        }
@@ -207,11 +206,9 @@ class wsTools
                        preg_match_all('/([\d\-\.]+)/', $attrs['transform'], $ma);
                        $values = $ma[0];
                        $scale = max($values[0], $values[1]);
-
                }
 
                $resolutionScale = ($iw / $attrs['width']) * $scale * (self::$_r / 72);
-               echo $resolutionScale . "\n";
 
                $dw = round($resolutionScale * $iw);
                $dh = round($resolutionScale * $ih);
index a776002bcf708d3cefc97b5353ffd9d469684a57..bd43ced8d2e85943648262f5ec9164f1582ee347 100644 (file)
@@ -1422,6 +1422,27 @@ class wsHTML5Compiler
                        $thisimagesvg = !$thisrasterize && $this->svg;
                        $thisbackgroundPrefix = $thisrasterize ? ['t'] : $this->backgroundsPrefix;
 
+                       foreach ($this->getResolutions() as $r) {
+                               foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
+                                       $srcPrefix = $backgroundsPrefix;
+                                       if ($backgroundsPrefix == 'p') {
+                                               $srcPrefix = 'h';
+                                       }
+                                       $source = $docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg';
+                                       if (!file_exists($source)) {
+                                               if (!isset($doc) || $doc->document_id != $infos['document_id']) {
+                                                       $dao = new wsDAODocument($core->con);
+                                                       $doc = $dao->selectById($infos['document_id']);
+                                               }
+                                               $doc->makeHTML5Files($infos['document_page']);
+                                       }
+                                       $ok = $this->vdir->copy($source, 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg');
+                                       if (!$ok && $r = 300) {
+                                               $this->maxRes = 150;
+                                       }
+                               }
+                       }
+
                        if ($thisimagesvg) {
                                $full = $docdir . 'html/fp' . $infos['document_page'] . '.svg';
                                $fullopt = $docdir . 'html/fo' . $infos['document_page'] . '%s.svg';
@@ -1446,18 +1467,6 @@ class wsHTML5Compiler
                                }
                        }
 
-                       foreach ($this->getResolutions() as $r) {
-                               foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
-                                       $srcPrefix = $backgroundsPrefix;
-                                       if ($backgroundsPrefix == 'p') {
-                                               $srcPrefix = 'h';
-                                       }
-                                       $ok = $this->vdir->copy($docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg');
-                                       if (!$ok && $r = 300) {
-                                               $this->maxRes = 150;
-                                       }
-                               }
-                       }
 
                        $thumb = false;
                        if ($this->book->parametres->pdfThumbnails) {