From fbcd179c04e2bd1061307bcabda70a9756b4217b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 6 Sep 2021 19:21:56 +0200 Subject: [PATCH] wip #4666 @1 --- src/Jobs/ProcessPage.php | 13 ++++++++----- src/PDF/Document.php | 8 ++++---- src/SVG/SVGTools.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/Jobs/ProcessPage.php b/src/Jobs/ProcessPage.php index e58c81f..a4ed202 100644 --- a/src/Jobs/ProcessPage.php +++ b/src/Jobs/ProcessPage.php @@ -31,23 +31,26 @@ class ProcessPage implements ShouldQueue /** * @var string */ - protected $dest; + protected $out; /** * @param $document Document * @param $page integer - * @param $dest string + * @param $out string */ - public function __construct($document, $page, $dest) + public function __construct($document, $page, $out, $files = []) { $this->document = $document; $this->page = $page; - $this->dest = $dest; + $this->out = $out; + $this->files = $files; } public function handle() { - + foreach ($this->files as $file) { + $this->getFile($this->page, $file['format'], $file['resolution'], $file['withText'], $file['withGraphics'], 'html', false); + } } diff --git a/src/PDF/Document.php b/src/PDF/Document.php index 9a10fd4..c3ebc57 100644 --- a/src/PDF/Document.php +++ b/src/PDF/Document.php @@ -81,10 +81,10 @@ class Document /** * @param $dest string */ - public function processPages($dest) + public function processPages($dest, $files) { for ($i = 1; $i <= $this->getPages(); $i++) { - $this->processPage($i, $dest); + $this->processPage($i, $dest, $files); } } @@ -92,8 +92,8 @@ class Document * @param $i * @param $dest */ - public function processPage($page, $dest) + public function processPage($page, $dest, $files) { - dispatch(new ProcessPage($this, $page, $dest)); + dispatch(new ProcessPage($this, $page, $dest, $files)); } } diff --git a/src/SVG/SVGTools.php b/src/SVG/SVGTools.php index 6d0ce82..de7ff93 100644 --- a/src/SVG/SVGTools.php +++ b/src/SVG/SVGTools.php @@ -6,6 +6,11 @@ use Cubist\Util\Files\Files; class SVGTools { + protected static $_r; + protected static $_i; + protected static $_e; + protected static $_u; + public static function optimizeSVG($in, $out = null) { if (null === $out) { @@ -53,6 +58,33 @@ class SVGTools file_put_contents($out, $osvg); } + protected static function _svg($c, $p) + { + self::$_i = 0; + self::$_e = 0; + self::$_u = 0; + + $c = str_replace('id="', 'id="p' . $p . '-', $c); + $c = str_replace('url(#', 'url(#p' . $p . '-', $c); + $c = str_replace('xlink:href="#', 'xlink:href="#p' . $p . '-', $c); + $c = preg_replace_callback('/\]*)\>/m', function ($matches) use ($p) { + self::$_i++; + return ''; + }, $c); + $c = str_replace('', '', $c); + + $c = preg_replace_callback('/