From: Vincent Vanwaelscappel Date: Fri, 8 Mar 2024 15:16:53 +0000 (+0100) Subject: wip #6781 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=015a0e26dacdbd8e1605b94d08179a6d88a2d4b8;p=fluidbook_tools.git wip #6781 @1 --- diff --git a/src/Jobs/ProcessFile.php b/src/Jobs/ProcessFile.php index 867a0a8..4bd729a 100644 --- a/src/Jobs/ProcessFile.php +++ b/src/Jobs/ProcessFile.php @@ -4,6 +4,7 @@ namespace Fluidbook\Tools\Jobs; use Cubist\Util\Files\Files; use Cubist\PDF\PDFTools; +use DOMDocument; use Fluidbook\Tools\SVG\SVGTools; class ProcessFile @@ -262,13 +263,21 @@ class ProcessFile public function makeSVGFile($force = false) { $svgFile = $this->getOut() . '/html/fp' . $this->getPage() . '.svg'; - if (!$force && file_exists($svgFile) && filesize($svgFile) > 0) { + if (!$force && file_exists($svgFile) && filesize($svgFile) > 0 && $this->_isSVGValid($svgFile)) { return $svgFile; } PDFTools::makeBaseSVGFile($this->getSplittedPDFPage(), $svgFile, 1); return $svgFile; } + protected function _isSVGValid($file) + { + $svg = new DOMDocument(); + $svg->preserveWhiteSpace = false; + $svg->load($file, LIBXML_PARSEHUGE); + return $svg->validate(); + } + public function makeTextSVGFile($out) { $in = $this->makeSVGFile(); @@ -306,7 +315,6 @@ class ProcessFile } - /** * @return int */