]> _ Git - cubeextranet.git/commitdiff
wait #4932 @0.75
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Dec 2021 07:57:10 +0000 (07:57 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Dec 2021 07:57:10 +0000 (07:57 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index 69c06e09f636580f493fdfad9e96e9acd6b583f8..b5c26ca27220910490accc5b483b9dc72202d3ed 100644 (file)
@@ -3089,20 +3089,34 @@ class articlePDFLink extends articleLink
         }
 
         $cut = $this->wdir . $name . '.c.pdf';
+        $sinfos = $this->wdir . $name . '.s.nfo';
         if (true || !file_exists($cut)) {
+            // Cut the pdf in many pages
             $ratio = $infos->width / $infos->height;
-            $nb = max(1, ceil(0.7 / $ratio));
+            $nb = max(1, ceil(0.707071 / $ratio));
 
             if ($nb == 1) {
                 copy($pdffile, $cut);
             } else {
                 `mutool poster -y $nb $pdffile $cut`;
             }
+
+            // Resize to 210mm width
+            $size = $this->wdir . $name . '.s.pdf';
+            `pdfposter $cut $size`;
+
+            $i = `pdfinfo -f 1 -l 1 -box $size`;
+            if (preg_match('/Page\s+1\s+size:\s+([0-9\.]+) x ([0-9\.]+)/', $i, $matches)) {
+                $infos = ['width' => $matches[1], 'height' => $matches[1] / $ratio];
+                file_put_contents($sinfos, json_encode($infos));
+            }
+        } else {
+            $infos = json_decode(file_get_contents($sinfos));
         }
 
-        $this->copyExternalFile($name . '.c.pdf');
+        $this->copyExternalFile($name . '.s.pdf');
         $text = file_get_contents($htmlfile);
-        $this->article = ['page' => $this->page, 'type' => 'pdf', 'id' => $name, 'url' => $name, 'infos' => $infos, 'content' => $name . '.c.pdf', 'textcontent' => $text];
+        $this->article = ['page' => $this->page, 'type' => 'pdf', 'id' => $name, 'url' => $name, 'infos' => $infos, 'content' => $name . '.s.pdf', 'textcontent' => $text];
         $this->compiler->config->articlesList[] = $this->article;
         $this->compiler->addSEOArticle('#/article/' . $name, $this->title, $this->description, '', $name, $name . '.html', $text);
     }