]> _ Git - fluidbook_tools.git/commitdiff
wait #7306 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Feb 2025 11:29:21 +0000 (12:29 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Feb 2025 11:29:21 +0000 (12:29 +0100)
src/Links/ArticlePDFLink.php

index 0f4d331dcffb6cd81ff4fc36dd8d10d144276a39..c7fe66de0ec66f942848c27d8a59de2074c80f96 100644 (file)
@@ -4,28 +4,34 @@ namespace Fluidbook\Tools\Links;
 
 use Cubist\Util\Graphics\Image;
 
-class ArticlePDFLink extends ArticleLink {
+class ArticlePDFLink extends ArticleLink
+{
     public $title = '';
     public $description = '';
 
-    public function init() {
-        $this->compiler->addPDFJS(true);
-
-        $wdir=$this->compiler->getWorkingDir();
+    public function init()
+    {
+        $wdir = $this->compiler->getWorkingDir();
 
         $e = explode('.', $this->to);
         array_pop($e);
         $name = implode('.', $e);
-        $pdffile =$wdir . $this->to;
+        $pdffile = $wdir . $this->to;
+        if (!file_exists($pdffile)) {
+            $this->compiler->addIssue(15, ['file' => $pdffile, 'uid' => $this->uid, 'page' => $this->page]);
+            return;
+        }
         $mtime = filemtime($pdffile);
 
-        $htmlfile =$wdir . $name . '.html';
+        $this->compiler->addPDFJS(true);
+
+        $htmlfile = $wdir . $name . '.html';
         if (!file_exists($htmlfile) || filemtime($htmlfile) < $mtime) {
             $cmd = "pdftotext -f 1 -l 1 -htmlmeta $pdffile $htmlfile";
             `$cmd`;
         }
 
-        $cut =$wdir . $name . '.c.pdf';
+        $cut = $wdir . $name . '.c.pdf';
         $size = $wdir . $name . '.s.pdf';
 
         $dim = Image::getimagesize($pdffile);