Skip to content

pageCount fails in newer versions of ghostscript #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
martinkoch-geniebelt opened this issue Apr 11, 2025 · 2 comments
Open

pageCount fails in newer versions of ghostscript #1823

martinkoch-geniebelt opened this issue Apr 11, 2025 · 2 comments
Milestone

Comments

@martinkoch-geniebelt
Copy link

Magick.NET version

14.5.0

Environment (Operating system, version and so on)

Ubuntu 24.04 (docker)

Description

When using pdfInfo.PageCount to get the number of pages, the system executes something like

'gs' -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT --permit-file-read='/tmp/file.pdf' -sPDFPassword='' -c '(/tmp/file.pdf) (r) file runpdfbegin pdfpagecount = quit'

However there seems to be a difference in newer versions of ghostscript that causes this to fail:

GPL Ghostscript 10.00.0: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.

It seems that passing -dNODISPLAY to gs makes this issue go away, but that is not done by default.

Steps to Reproduce

Running the above command on older / newer versions of ghostscript.

Images

n/a

@dlemstra dlemstra added this to the 14.7.0 milestone Apr 12, 2025
@dlemstra
Copy link
Owner

dlemstra commented Apr 12, 2025

I suspect this must be related to the file that you are using or maybe even a change in their latest patches. I just pushed a patch to add the -dNODISPLAY in the native library because it does seem the right way to do this according to their documentation. There are unit tests on both Windows and Linux that use Ghostscript 10.0.0 so we should know what this change does after I upgrade the native library here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@dlemstra @martinkoch-geniebelt and others