Corrupted PDF with lualatex + gs 10.04.0

Bruno Voisin bvoisin at icloud.com
Thu Dec 19 04:16:12 CET 2024


> Denis Bitouzé wrote on this list:
> 
> Consider the following simple `test.tex` source file:
> 
> \documentclass{article}
> \begin{document}
> Foo.
> \end{document}
> 
> [...] if it is compiled with `lualatex` (only) and
> if the resulting PDF is subject to:
> 
> gs -P- -dSAFER -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr "-sOutputFile=test.pdf.pdf" -P- -dSAFER test.pdf
> 
> [..] then, with `gs` (version
> 10.04.0), the “Foo.” text in `test.pdf.pdf`, if copied and pasted,
> returns:
> 
> 6QQX

I can confirm this on the Mac, but only provided the PDF files are opened with Acrobat. If the PDF files are opened with the macOS built-in Preview, copy-and-paste gives "Foo." with both PDF files (ie, LuaTeX-produced test.pdf and Ghostscript-produced test.pdf.pdf).


> Denis wrote later:
> 
> OK. Do you know what would be the best place and the best way to report
> this issue?

The gs-devel list (suggested by Zdenek and Reinhard) lives at

https://www.ghostscript.com/mailman/index.html

You need to subscribe to be able to post, IIRC. There used to be a public archive, but it couldn't be brought back online after the list server switched from mailman 2 to 3.

The other option, which Denis used, is Bugzilla

https://bugs.ghostscript.com

As you saw, the developers are quite responsive.


> Following Ken Sharp's answer on Bugzilla, Denis asked there:
> 
> Could you please explain in what the current bug is a duplicate of bug 708042, and what to do to get rid of this issue?

Attempting a quick answer here:

- Ken explains this by a non-standard ToUnicode CMap

https://bugs.ghostscript.com/show_bug.cgi?id=708042#c3

(though the CMap given there differs from those reported by Zdenek).

- gs 10.04.0 was released on September 18, whereas Ken's commit (fixing the issue) is from the next day, September 19. Thus you need to get the development 10.05.0 version, say with

git clone -b master https://git.ghostscript.com/ghostpdl.git

and compile it. Or just apply the commit

https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/commit/?id=65f6ea3c1660ea05b6a575cbe738e66e54b9a497

to the 10.04.0 sources

https://www.ghostscript.com/releases/gsdnld.html

and compile the result.

On the Mac, you need to install m4, autoconf and automake first (in this order). Then, for gs, you compile with

./autogen.sh --disable-compile-inits
make gs
sudo make install

After that, the problem's gone. Namely, using gs 10.04.0, opening the PDF file in Acrobat, copying the content and pasting it in a text editor, I get

􀀶􀁑􀁑􀁘

Doing the same with the 10.05.0 development version, I get

Foo.


Bruno Voisin




More information about the tex-live mailing list.