From cd178fcfa33226d2840ac9b5c64c14fb0b630566 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 19 Jan 2022 13:56:09 +0100 Subject: [PATCH] wip #4804 @0.5 --- .idea/runConfigurations.xml | 10 ---------- src/Document.php | 16 +++++++++++----- 2 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 .idea/runConfigurations.xml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Document.php b/src/Document.php index c3a006e..da341c1 100644 --- a/src/Document.php +++ b/src/Document.php @@ -69,12 +69,18 @@ class Document return; } - $fwstk = new FWSTK(); - $fwstk->setArg('--input ' . $this->getPDFInput()); - $fwstk->setArg('--infos'); - $fwstk->execute(); + $nfoFile = $this->getConvertPath() . 'infos'; - $infos = $fwstk->getOutput(); + if (!file_exists($nfoFile) || filesize($nfoFile) === 0 || filemtime($nfoFile) < filemtime($this->getPDFInput())) { + $fwstk = new FWSTK(); + $fwstk->setArg('--input ' . $this->getPDFInput()); + $fwstk->setArg('--infos'); + $fwstk->execute(); + + $infos = $fwstk->getOutput(); + } else { + $infos = file_get_contents($nfoFile); + } if (preg_match('/Pages:\s*(\d+)/', $infos, $matches)) { -- 2.39.5