]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Apr 2011 18:30:43 +0000 (18:30 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Apr 2011 18:30:43 +0000 (18:30 +0000)
inc/ws/Metier/class.ws.document.php
inc/ws/Util/class.ws.swf2html.php
inc/ws/Util/packager/class.ws.packager.html5.php

index 28d5c3eb7490f29c557420bab9c1dc54caf42572..5307b4b508335dbec223adacc3d823cbfffb4dc2 100644 (file)
@@ -518,12 +518,13 @@ class wsDocument extends cubeMetier {
                $this->addToLog($gs, true, $page);\r
        }\r
 \r
-       protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)\r
+       protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null, $texts = true)\r
        {\r
                if (is_null($in)) {\r
                        $in = $this->cropped;\r
                }\r
                $antialiasing = $antialiasing?'yes':'no';\r
+               $freetype = $texts?'yes':'no';\r
                $resolution = round($resolution);\r
                // Exporte les fichiers\r
                $pdftoppm = new cubeCommandLine('pdftoppm', null, true);\r
@@ -533,7 +534,7 @@ class wsDocument extends cubeMetier {
                $pdftoppm->setArg('l', $page);\r
 \r
                $pdftoppm->setArg('-cropbox');\r
-               $pdftoppm->setArg('-freetype yes');\r
+               $pdftoppm->setArg('-freetype ' . $freetype);\r
                $pdftoppm->setArg('-jpeg');\r
                $pdftoppm->setArg('-aa ' . $antialiasing);\r
                $pdftoppm->setArg('-aaVector ' . $antialiasing);\r
@@ -626,15 +627,19 @@ class wsDocument extends cubeMetier {
        public function makeHTML5Files($page)\r
        {\r
                // First, make swf with polytobitmap to rasterize bitmap & vectors\r
-               $this->pdf2swf($page, 150, 90, true, self::POLY2BITMAP, 'h');\r
+               $this->pdf2swf($page, 72, 80, true, self::POLY2BITMAP, 'h');\r
                // Then get the special unicode dump\r
                $dump = $this->dumpSWF($page, 'h');\r
                // Then, process it\r
                $swf2html = new wsSWF2HTML($dump);\r
                $swf2html->process();\r
                $this->addToLog(print_r($swf2html, true), true, $page);\r
-\r
                file_put_contents($this->html . '/p' . $page . '.obj', serialize($swf2html));\r
+               // Then make HD background shots\r
+               $resolutions = array(36 => 80, 72 => 70, 150 => 50);\r
+               foreach($resolutions as $r => $q) {\r
+                       $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false);\r
+               }\r
        }\r
 \r
        protected function checkObjectsNumber($file, $maxObjects, $page)\r
index 6280de9a2bdea0e33d4ba550b12a7d123b93299a..f87f3d82d55cd09c74e72125b2f78e18c72ed6af 100644 (file)
@@ -2,6 +2,7 @@
 class wsSWF2HTML {\r
        const FONT_TAG = '04b';\r
        const TEXT_TAG = '021';\r
+       const IMAGE_TAG='';\r
 \r
        public $lines;\r
        public $tags = array();\r
index 1c180ff243aab6d6d5a3ce3e92d1538fe410dc5d..d54f3e147c4f8e12cc9013f04102e13d9eaa9ad4 100644 (file)
@@ -58,6 +58,12 @@ class wsPackagerHTML5 extends wsPackager {
                foreach($this->div as $n => $page) {\r
                        file_put_contents($this->vdir . '/contents/p' . $n . '.html', $this->writePage($page));\r
                }\r
+               $this->writeFonts();\r
+               $this->writeImages();\r
+       }\r
+\r
+       protected function writeFonts()\r
+       {\r
                $fext = array('ttf', 'eot', 'svg', 'svgz', 'woff');\r
                foreach($this->fonts as $font) {\r
                        if (!$font['embed']) {\r
@@ -69,6 +75,19 @@ class wsPackagerHTML5 extends wsPackager {
                }\r
        }\r
 \r
+       protected function writeImages()\r
+       {\r
+               $resolutions = array(36, 72, 150);\r
+               foreach($resolutions as $r) {\r
+                       mkdir($this->vdir . '/images/' . $r, 0777);\r
+               }\r
+               foreach($this->pages as $page => $infos) {\r
+                       foreach($resolutions as $r) {\r
+                               copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/images/' . $r . '/p' . $page . '.jpg');\r
+                       }\r
+               }\r
+       }\r
+\r
        protected function writePage($page)\r
        {\r
                $res = '';\r
@@ -80,7 +99,7 @@ class wsPackagerHTML5 extends wsPackager {
 \r
        protected function writeDiv($div)\r
        {\r
-               $res = '<div style="left:' . $div['left'] . 'px;top:' . $div['top'] . 'px;">';\r
+               $res = '<div style="left:' . ($div['left'] * 2) . 'px;top:' . ($div['top'] * 2) . 'px;">';\r
                foreach($div['span'] as $span) {\r
                        $res .= $this->writeSpan($span);\r
                }\r
@@ -91,7 +110,7 @@ class wsPackagerHTML5 extends wsPackager {
        protected function writeSpan($span)\r
        {\r
                $res = '<span ';\r
-               $res .= 'style="left:' . $span['left'] . 'px;top:' . $span['top'] . 'px" ';\r
+               $res .= 'style="left:' . ($span['left'] * 2) . 'px;top:' . ($span['top'] * 2) . 'px" ';\r
                $res .= 'class="c' . $span['color'] . ' s' . $span['size'] . ' f' . $span['font'] . '"';\r
                $res .= '>';\r
                $res .= htmlentities($span['text'], ENT_NOQUOTES, 'UTF-8');\r
@@ -105,8 +124,10 @@ class wsPackagerHTML5 extends wsPackager {
                foreach($this->cssColor as $color => $index) {\r
                        $res[] = '.c' . $index . '{color:' . $color . ';}';\r
                }\r
+\r
                foreach($this->cssSize as $size => $index) {\r
-                       $res[] = '.s' . $index . '{font-size:' . $size . 'px;}';\r
+                       $size /= 100;\r
+                       $res[] = '.s' . $index . '{font-size:' . $size . 'em;}';\r
                }\r
 \r
                foreach($this->fonts as $id => $font) {\r
@@ -116,7 +137,7 @@ class wsPackagerHTML5 extends wsPackager {
                                        $svgid = $f['id'];\r
                                        break;\r
                                }\r
-                               $res[] = "@font-face{font-family:'" . $font['name'] . "';src:url('" . $font['name'] . ".eot');src:url('" . $font['name'] . ".eot?#iefix') format('eot'),url('" . $font['name'] . ".woff') format('woff'),url('" . $font['name'] . ".ttf') format('truetype'),url('" . $font['name'] . ".svgz#" . $svgid . "') format('svgz'),url('" . $font['name'] . ".svg#" . $svgid . "') format('svg');font-weight:normal;font-style:normal;}";\r
+                               $res[] = "@font-face{font-family:'" . $font['name'] . "';src:url('" . $font['url'] . ".eot');src:url('" . $font['url'] . ".eot?#iefix') format('eot'),url('" . $font['url'] . ".woff') format('woff'),url('" . $font['url'] . ".ttf') format('truetype'),url('" . $font['url'] . ".svgz#" . $svgid . "') format('svgz'),url('" . $font['url'] . ".svg#" . $svgid . "') format('svg');font-weight:normal;font-style:normal;}";\r
                                $res[] = '.f' . $font['index'] . '{font-family:' . $font['name'] . ',Arial,Helvetica;}';\r
                        } else {\r
                                $res[] = '.f' . $font['index'] . '{font-family:' . $font['realname'] . ',Arial,Helvetica;}';\r
@@ -134,7 +155,7 @@ class wsPackagerHTML5 extends wsPackager {
                $index = $this->fontsCount;\r
                $file = WS_DOCS . '/' . $infos['document_id'] . '/fonts/web/' . $tag->name;\r
                $embed = file_exists($file . '.ttf');\r
-               $this->fonts[$tag->name] = array('index' => $index, 'realname' => $tag->name, 'name' => 'FB' . $index, 'file' => $file, 'embed' => $embed);\r
+               $this->fonts[$tag->name] = array('index' => $index, 'realname' => $tag->name, 'name' => 'FB' . $index, 'file' => $file, 'embed' => $embed, 'url' => '../fonts/FB' . $index);\r
                $this->fontsCount++;\r
        }\r
 \r
@@ -142,13 +163,21 @@ class wsPackagerHTML5 extends wsPackager {
        {\r
                $d = array('span' => array(), 'left' => $tag->left, 'top' => $tag->top);\r
                foreach($tag->textes as $text) {\r
-                       $d['span'][] = $this->addCSSText($text, $page);\r
+                       $s = $this->addCSSText($text, $page);\r
+                       if ($s === false) {\r
+                               continue;\r
+                       }\r
+                       $d['span'][] = $s;\r
                }\r
                $div[] = $d;\r
        }\r
 \r
        protected function addCSSText($text, $page)\r
        {\r
+               $alpha = intval(substr($text->color, -2), 16);\r
+               if ($alpha == 0) {\r
+                       return false;\r
+               }\r
                return array('text' => $text->text,\r
                        'color' => $this->getCSSColor($text->color),\r
                        'size' => $this->getCSSSize($text->size),\r
@@ -179,6 +208,7 @@ class wsPackagerHTML5 extends wsPackager {
 \r
        protected function getIndex($value, &$tab)\r
        {\r
+               $value = (string)$value;\r
                if (isset($tab[$value])) {\r
                        return $tab[$value];\r
                }\r