From 6ca9084e484408195e2db7d8c9cc3e0475ef0055 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 2 Dec 2021 20:08:26 +0000 Subject: [PATCH] wip #4932 @0.75 --- .../Util/html5/master/class.ws.html5.links.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index d01523392..69c06e09f 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -3088,9 +3088,21 @@ class articlePDFLink extends articleLink $infos = json_decode(file_get_contents($infosfile)); } - $this->copyExternalFile($this->to); + $cut = $this->wdir . $name . '.c.pdf'; + if (true || !file_exists($cut)) { + $ratio = $infos->width / $infos->height; + $nb = max(1, ceil(0.7 / $ratio)); + + if ($nb == 1) { + copy($pdffile, $cut); + } else { + `mutool poster -y $nb $pdffile $cut`; + } + } + + $this->copyExternalFile($name . '.c.pdf'); $text = file_get_contents($htmlfile); - $this->article = ['page' => $this->page, 'type' => 'pdf', 'id' => $name, 'url' => $name, 'infos' => $infos, 'content' => $this->to, 'textcontent' => $text]; + $this->article = ['page' => $this->page, 'type' => 'pdf', 'id' => $name, 'url' => $name, 'infos' => $infos, 'content' => $name . '.c.pdf', 'textcontent' => $text]; $this->compiler->config->articlesList[] = $this->article; $this->compiler->addSEOArticle('#/article/' . $name, $this->title, $this->description, '', $name, $name . '.html', $text); } -- 2.39.5