0

I'm trying to use ps2pdf to convert a Postscript file to PDF, but the Postscript file has a UTF-8 character in it which is not rendered properly.

We have a website with a database, where users can enter their names and do some things and they get a printable PDF certificate. It has worked for years without trouble, until recently when it was used by someone with 'ñ' in their name. (Apparently this has never happened before.)

The database has it in the field fine. There's a Perl script (of unknown age) which gets the data out of the database and assembles a Postscript file, and that looks okay too:

63 688 206 (Peña) 26 tline

I have checked the Postscript; the character 'ñ' is the two-byte UTF-8 encoding 0xc3 and 0xb1.

But when I run that through ps2pdf, the PDF shows the two characters '^-'. Searching online and reading the manuals has given me answers that don't seem to work. Using iconv -f utf8 certificate.ps -t utf16 -o certificate.pdf seems to have done the right thing, but ps2pdf doesn't seem to like UTF-16 input, because it prints Error: /undefined in ��.

It feels like there's something obvious that I'm missing, but since I'm missing it I don't know what it is. Is there some way to get ghostscript to handle UTF-8 input?

3
  • 2
    PostScript doesn't support UTF-8, not at all. Nor UTF-16. So if your program is using it, then it won't work. It could be using an encoded CIDFont but that isn't the same thing. Ghostscript's pdfwrite device is known to work with CIDFonts and a broad range of languages. If you think you have found a bug then you should report it as such. My guess is that your Perl script is too simple and just inserts the character as if it were ASCII, and that simply won't work in PostScript. The ntilde glyph is encoded at octal 361 (0xF1) in StandardEncoding so as K J says try using that instead of UTF-8. Commented Apr 18, 2024 at 7:05
  • I don't get it. Why does Ghostscript doesn't handle UTF-8 when it's a defacto standard Commented Nov 23, 2024 at 16:17
  • Did you manage to get it working? Commented Nov 23, 2024 at 16:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.