\r
public function makeSVGFile($page) {\r
$svgFile = $this->out . '/html/p' . $page . '.svg';\r
- $svgzFile = $this->out . '/html/p' . $page . '.svgz';\r
+ $svgOpt = $this->out . '/html/o' . $page . '.svg';\r
\r
$pdf2svg = new cubeCommandLine('pdf2svg');\r
$pdf2svg->setPath(CONVERTER_PATH);\r
$this->addToLog($pdf2svg, true, $page);\r
\r
$svg = new DOMDocument();\r
- $svg->preserveWhiteSpace=false;\r
+ $svg->preserveWhiteSpace = false;\r
$svg->load($svgFile);\r
\r
// Operations to delete \r
'//svg:defs/svg:image',\r
'//svg:defs/svg:pattern',\r
'/svg:svg/svg:g/svg:g[not(svg:use[@xlink:href])]',\r
- '/svg:svg/svg:g/svg:path'\r
+ '/svg:svg/svg:g/svg:path',\r
+ '/svg:svg/svg:g/rect:path',\r
);\r
\r
global $svglog;\r
\r
$this->addToLog(implode("\n", $svglog), false, $page);\r
file_put_contents($svgFile, $svg->saveXML());\r
+\r
+ $scour = new cubeCommandLine('scour.py');\r
+ $scour->setArg('shorten-ids');\r
+ $scour->setArg('set-precision', '3');\r
+ $scour->setArg('indent', 'none');\r
+ $scour->setArg('create-groups');\r
+ $scour->setArg('i', $svgFile);\r
+ $scour->setArg('o', $svgOpt);\r
+ $scour->setNohup(true);\r
+ $scour->execute();\r
}\r
\r
protected function checkObjectsNumber($file, $maxObjects, $page) {\r
protected $cssOneWidth;
protected $cssOneHeight;
protected $cssScale;
- protected $cssSVGScale = 0.75;
+ protected $cssSVGScale;
protected $optimalWidth = 567;
protected $optimalHeight = 709;
protected $additionalConfig = array();
$firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
$size = $firstDoc->generalInfos['size'];
- $this->width = round($size[0], 2);
- $this->height = round($size[1], 2);
+ $this->width = round($size[0], 3);
+ $this->height = round($size[1], 3);
$imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h150-' . $this->pages[1]['document_page'] . '.jpg');
- $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 2);
+ $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 3);
$this->cssScale = min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
$this->cssOneScale = min(($this->optimalWidth * 2) / $this->width, $this->optimalHeight / $this->height);
$this->cssOneWidth = $this->width * $this->cssOneScale;
$this->cssOneHeight = $this->height * $this->cssOneScale;
+
+ $this->cssSVGScale=0.75/2;
$this->scale = 1;
if ($this->book->parametres->zoomMode == 1) {
foreach (self::$resolutions as $r) {
mkdir($this->vdir . '/data/background/' . $r, 0777, true);
}
- $srcPrefix=$this->backgroundsPrefix;
+ $srcPrefix = $this->backgroundsPrefix;
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');
+ $orig = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.svg';
+ $opt = WS_DOCS . '/' . $infos['document_id'] . '/html/o' . $infos['document_page'] . '.svg';
+
+ $svg = $orig;
+ if (file_exists($opt) && filesize($opt) > 0) {
+ $svg = $opt;
+ }
+
+ $this->copy($svg, $this->vdir . '/data/contents/p' . $page . '.svg');
}
foreach (self::$resolutions as $r) {
$this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg');
$wm = ($this->width * $this->multiply) . 'px';
$hm = ($this->height * $this->multiply) . 'px';
$w = $cssWidth . 'px';
- $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 2);
+ $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 3);
$offsetLeft2 = $offsetLeft * 2;
- $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 2);
+ $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 3);
$navTop = ($cssHeight - 40 - 100) / 2;
$res[] = '#fluidbook{left:' . $offsetLeft . 'px;top:' . $offsetTop . 'px;}';
$res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';
foreach (self::$resolutions as $r) {
- $ratio = round(72 / $r, 2) * $cssScale;
+ $ratio = round(72 / $r, 3) * $cssScale;
$wr = $cssWidth / $ratio;
$hr = $cssHeight / $ratio;
$res[] = $br;
}
$texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';';
- $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.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
+ $texts.='width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';';
+ $texts.='height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';';
$texts.='}';
$res[] = $texts;