Last page missing if PDF has odd number of pages

Created on 8 September 2024, 3 months ago

Problem/Motivation

On our production site, we noticed that some PDFs were missing a page and some were not. Further investigation revealed that if a PDF has an odd number of pages, the last page is omitted during image processing. It does not show up in the file directory.

Steps to reproduce

Tested on a fresh install.
Drupal 10.3.2
PHP 8.1.29
Install module and follow instructions to add fields.

Upload PDF with 2 pages, save, and see 2 images.
Upload PDF with 3 pages, save, and see 2 images.
Upload PDF with 4 pages, save, and see 4 images.
Upload PDF with 5 pages, save, and see 4 images.
Upload PDF with 6 pages, save, and see 6 images.
etc...

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany markdc Hamburg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @markdc
  • 🇩🇪Germany markdc Hamburg

    Could anyone else verify that this error exists?

  • 🇨🇦Canada blnicholas

    Hi, I have tested this on Drupal 10.3.2 with PHP 8.3.9 (didn't downgrade to your php version) and processed both 3 & 5 page PDFs.

    The correct amount of images processed and the last image (odd) were showing for the node.

  • 🇨🇦Canada blnicholas

    Hi,

    I have downgraded my php version to match 8.1.29. I was still able to see the last page for PDFs with odd number of pages.

    Perhaps it could be the PDFs. Have you tried other PDFs? I tested with samples I downloaded from googling.

    Also could be an issue with imagemagik or spatie/pdf-to-image.

    I would also look for any errors in the server logs.

    Attaching my imagick extension details.


    Hope this helps!

  • 🇩🇪Germany markdc Hamburg

    Thank you for the feedback. This helps me to narrow the troubleshooting.

    I've tested with a variety of PDFs from different sources, as well as simple ones I exported myself from Apple Pages.

    So its either imagemagik or spatie/pdf-to-image.
    I see my imagemagik is older than yours. I'll start there.

  • 🇩🇪Germany markdc Hamburg

    I've updated to PHP 8.3.13.
    But I'm having difficulty updating to ImageMagick 7 because my server is still on Ubuntu 20.

    I discovered a temporary workaround. If I increase the batch page processing from 1 to 5 for example, then 3 and 5-page PDFs are processed completely. But anything over that — 7, 9, etc — is still missing the last page.

    I'll continue to search for a solution.

Production build 0.71.5 2024