diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 969d7b8..46a5ceb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,6 +15,11 @@ jobs: name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} steps: + - name: Upgrade ghostscript + run: | + sudo apt-get update + sudo apt-get install ghostscript + - name: Checkout code uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index d52489a..9bc04df 100644 --- a/composer.json +++ b/composer.json @@ -37,5 +37,11 @@ }, "scripts": { "test": "vendor/bin/pest" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } } } diff --git a/src/Pdf.php b/src/Pdf.php index b990eb3..2bf06d0 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -42,9 +42,7 @@ public function __construct(string $pdfFile) $this->imagick = new Imagick(); - $this->imagick->pingImage($pdfFile); - - $this->numberOfPages = $this->imagick->getNumberImages(); + $this->imagick->readImage($this->pdfFile); } public function setResolution(int $resolution) @@ -109,6 +107,10 @@ public function setPage(int $page) public function getNumberOfPages(): int { + if ($this->numberOfPages === null) { + $this->numberOfPages = $this->imagick->getNumberImages(); + } + return $this->numberOfPages; }