Skip to content

pageCount fails in newer versions of ghostscript #1823

@martinkoch-geniebelt

Description

@martinkoch-geniebelt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions