]> _ Git - fluidbook_tools.git/commitdiff
wip #4666 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 6 Sep 2021 17:21:56 +0000 (19:21 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 6 Sep 2021 17:21:56 +0000 (19:21 +0200)
src/Jobs/ProcessPage.php
src/PDF/Document.php
src/SVG/SVGTools.php

index e58c81f61ff2fa2594e693fffaf8fb8e1e1061e5..a4ed2022e44b451f209b904ac1d71c700e5acf29 100644 (file)
@@ -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);
+        }
     }
 
 
index 9a10fd4222be69423d16b90081e07c742f98a537..c3ebc578148595b7d4efe9520a31f6f87511e873 100644 (file)
@@ -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));
     }
 }
index 6d0ce82c0e407918c9d5ce845bb411a7ee43fb44..de7ff934f94de2f2e123aa1ee0990595e0cc8165 100644 (file)
@@ -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('/\<image([^\>]*)\>/m', function ($matches) use ($p) {
+            self::$_i++;
+            return '<g id="p' . $p . '-imageholder-' . self::$_i . '"><image id="p' . $p . '-image-' . self::$_i . '" ' . $matches[1] . '></g>';
+        }, $c);
+        $c = str_replace('</image>', '</image></g></g>', $c);
+
+        $c = preg_replace_callback('/<path /', function () use ($p) {
+            self::$_e++;
+            return '<path id="p' . $p . '-e-' . self::$_e . '" ';
+        }, $c);
+        $c = preg_replace_callback('/<use /', function () use ($p) {
+            self::$_u++;
+            return '<use id="p' . $p . '-u-' . self::$_u . '" ';
+        }, $c);
+
+        return $c;
+    }
+
     public static function optimizeRaster($matches, $resolution)
     {
         preg_match_all('/([a-z\:\-]*)="([^"]*)"/', $matches[1], $m);