raffaem / pdfsak

Utility to manipulate PDF files.
MIT License
43 stars 8 forks source link

pdfsak fails with Ghostscript >= 9.56.1 #14

Closed BartMassey closed 2 years ago

BartMassey commented 2 years ago

Describe the bug When invoked on Linux, pdfsak fails altogether with an error about page numbering failure. The error message is not well-formatted.

To Reproduce

pdfsak -t '$page' br 1 1 -if input.pdf -o output.pdf

Expected behavior Expected pdfsak to page number my file.

System information Please paste the output of pdfsak --check-all here:

os.name: posix
platform.system(): Linux
platform.release(): 5.18.0-4-amd64
CWD: /tmp/pdfsakcq9l_w7g
PATH: 
<redacted>
Python: 3.10.6 (main, Aug 10 2022, 11:19:32) [GCC 12.1.0]
PDFsak version: 1.3.0
pdflatex OK (1.40.24 >= 1.40.17): pdfTeX 3.141592653-2.6-1.40.24 (TeX Live 2022/Debian)
Checking LaTeX package 'grffile' OK: 2019/11/11 v2.1
Checking LaTeX package 'pdfpages' OK: 2022/05/22 v0.5v
Checking LaTeX package 'lastpage' OK: 2021/09/03 v1.2n
Checking LaTeX package 'fancyhdr' OK: 2022/05/18 v4.0.3
Checking LaTeX package 'geometry' OK: 2020/01/02 v5.9
Checking LaTeX package 'calc' OK: 2017/05/25 v4.3
Checking LaTeX package 'graphicx' OK: 2021/09/16 v1.2d
Checking LaTeX package 'transparent' OK: 2019/11/29 v1.4
Checking LaTeX package 'xparse' OK: 2022-06-22 L3
Checking LaTeX package 'letltxmacro' OK: 2019/12/03 v1.6
Checking LaTeX package 'changepage' OK: 2009/10/20 v1.0c
Checking LaTeX package 'textpos' OK: 2020/09/26 v1.10
ImageMagick NOT FOUND
Potrace NOT FOUND
mkbitmap NOT FOUND
Ghostscript OK: 9.56.1

Will submit a PR which closes this in a moment.

raffaem commented 2 years ago

This is due to the new PDF interpreter in Ghostscript 9.56.1.

It doesn't work for me even with your PR:

$ ../../../pdfsak --input-file ../../input/article1.pdf --output ../../output/addtext.pdf -t "$page" tl 0 0 --overwrite
ERROR: Cannot get page count.
 cmd: ['gs', '-q', '-dNOSAFER', '-dNODISPLAY', '-c', '(/mnt/dataint/data/progetti_miei/pdfsak/examples/input/article1.pdf) (r) file runpdfbegin pdfpagecount = quit']
stdout: 32

stderr: free(): double free detected in tcache 2

As a temporary workaround downgrade Ghostscript to 9.55

raffaem commented 2 years ago

Yes, your PR allows PDFsak to work with Ghoscript >= 9.56.

The additional error is due to -dNODISPLAY, and is most likely a bug of Ghostscript 9.56.1. I opened a bug report, I'm gonna remove that option for the time being.

Thank you very much for this PR!

I will release a new version soon.