From: vincent@cubedesigners.com Date: Sun, 18 Mar 2012 22:57:34 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ffa4493d945646338379ff6b575f529f3fa72dda;p=cubeextranet.git --- diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 547341dbc..3705613fc 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -259,7 +259,6 @@ class wsDocument extends cubeMetier { if ($this->CropAndCut()) { $this->getInfos($this->cropped, true); } - //$this->extractFonts(); $this->getLinksAndTexts(); } @@ -331,14 +330,14 @@ class wsDocument extends cubeMetier { $fwstk->execute(); $this->addToLog($fwstk); - /*$fwstk = new cubeCommandLine('fwstk'); - $fwstk->setPath(CONVERTER_PATH); - $fwstk->setArg('--input ' . $this->cropped); - $fwstk->setArg('--layout ' . $this->html . 'p%d.layout'); - $fwstk->setArg('--cmaps ' . $this->html); - $fwstk->setArg('--fonts' . $this->out . 'fonts/web/'); - $fwstk->execute(); - $this->addToLog($fwstk);*/ + /* $fwstk = new cubeCommandLine('fwstk'); + $fwstk->setPath(CONVERTER_PATH); + $fwstk->setArg('--input ' . $this->cropped); + $fwstk->setArg('--layout ' . $this->html . 'p%d.layout'); + $fwstk->setArg('--cmaps ' . $this->html); + $fwstk->setArg('--fonts' . $this->out . 'fonts/web/'); + $fwstk->execute(); + $this->addToLog($fwstk); */ } public function makeMiniShot($page) { @@ -543,6 +542,56 @@ class wsDocument extends cubeMetier { $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false); $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true); } + + $this->makeSVGFile($page); + } + + public function makeSVGFile($page) { + $svgFile = $this->out . '/html/p' . $page . '.svg'; + $svgzFile = $this->out . '/html/p' . $page . '.svgz'; + + $pdf2svg = new cubeCommandLine('pdf2svg'); + $pdf2svg->setPath(CONVERTER_PATH); + $pdf2svg->setArg(null, $this->cropped); + $pdf2svg->setArg(null, $svgFile); + $pdf2svg->setArg(null, $page); + $pdf2svg->execute(); + $this->addToLog($pdf2svg, true, $page); + + $svg = new DOMDocument(); + $svg->preserveWhiteSpace=false; + $svg->load($svgFile); + + // Operations to delete + $xpath = new DOMXPath($svg); + $xpath->registerNamespace('svg', 'http://www.w3.org/2000/svg'); + $xpath->registerNamespace('xlink', 'http://www.w3.org/1999/xlink'); + $xpath->registerNamespace("php", "http://php.net/xpath"); + $xpath->registerPhpFunctions('has_not_text'); + $toDelete = array('//svg:defs/svg:clipPath', + '//svg:defs/svg:image', + '//svg:defs/svg:pattern', + '/svg:svg/svg:g/svg:g[not(svg:use[@xlink:href])]', + '/svg:svg/svg:g/svg:path' + ); + + global $svglog; + $svglog = array('XPATH : ' . print_r($xpath, true)); + foreach ($toDelete as $q) { + $list = $xpath->query($q); + $svglog[] = "Evaluate xpath query " . $q; + $svglog[] = 'Give ' . $list->length . ' results'; + $svglog[] = 'Deleting Nodes in ' . print_r($list, true); + foreach ($list as $node) { + + /* @var $node DOMNode */ + $parent = $node->parentNode; + $parent->removeChild($node); + } + } + + $this->addToLog(implode("\n", $svglog), false, $page); + file_put_contents($svgFile, $svg->saveXML()); } protected function checkObjectsNumber($file, $maxObjects, $page) { @@ -705,10 +754,10 @@ class wsDocument extends cubeMetier { $pdf2swf->setArg('set jpegquality', $quality); $pdf2swf->setArg('set disablelinks'); $pdf2swf->setArg('set dots'); - /*if(file_exists($this->rgb)){ - $pdf2swf->setArg(null, $this->rgb); - }else{*/ - $pdf2swf->setArg(null, $this->cropped); + /* if(file_exists($this->rgb)){ + $pdf2swf->setArg(null, $this->rgb); + }else{ */ + $pdf2swf->setArg(null, $this->cropped); //} $pdf2swf->setArg('output', $this->out . $prefix . '%.swf'); $pdf2swf->execute(); diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index a23cab957..da091c080 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -58,12 +58,14 @@ class wsHTML5Compiler { protected $cssOneWidth; protected $cssOneHeight; protected $cssScale; + protected $cssSVGScale = 0.75; protected $optimalWidth = 567; protected $optimalHeight = 709; protected $additionalConfig = array(); protected $fontScale = 1; protected $cache = array(); protected $backgroundsPrefix = 'p'; + protected $svg = true; function __construct($book_id) { global $core; @@ -89,6 +91,7 @@ class wsHTML5Compiler { if ($this->book->parametres->mobileVersion == 'html5-images') { $this->backgroundsPrefix = 't'; + $this->svg = false; } $daoTheme = new wsDAOTheme($core->con); @@ -115,7 +118,7 @@ class wsHTML5Compiler { $this->cssOneWidth = $this->width * $this->cssOneScale; $this->cssOneHeight = $this->height * $this->cssOneScale; - $this->scale = 10; + $this->scale = 1; if ($this->book->parametres->zoomMode == 1) { $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssOneScale; } else { @@ -448,13 +451,18 @@ class wsHTML5Compiler { } protected function writeImages() { - foreach (self::$resolutions as $r) { mkdir($this->vdir . '/data/background/' . $r, 0777, true); } + if ($this->backgroundsPrefix == 'p') { + $srcPrefix = 'h'; + } foreach ($this->pages as $page => $infos) { + if ($this->svg) { + $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.svg', $this->vdir . '/data/contents/p' . $page . '.svg'); + } foreach (self::$resolutions as $r) { - $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $this->backgroundsPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg'); + $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg'); } $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg'); } @@ -462,6 +470,7 @@ class wsHTML5Compiler { protected function copy($s, $t) { if (!file_exists($s)) { + fb($s . ' dont exists'); return; } if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) { @@ -520,9 +529,9 @@ class wsHTML5Compiler { $res[] = $br; } $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; - $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale, 2) . ')') . ';'; - $texts.='width:' . $wm . '; max-width:' . $wm . ';'; - $texts.='height:' . $hm . '; max-height:' . $hm . ';'; + $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 2) . ')') . ';'; + $texts.='width:' . ($wm/$this->cssSVGScale) . '; max-width:' . ($wm/$this->cssSVGScale). ';'; + $texts.='height:' . ($hm/$this->cssSVGScale) . '; max-height:' . ($hm/$this->cssSVGScale) . ';'; $texts.='}'; $res[] = $texts;