7

I have problem converting a file to PDF. I create the file with

echo ęąśćżńł > text 

and convert:

enscript -O text -o - | ps2pdf - out.pdf 

However, out.pdf has an encoding problem:

screenshot of corrupted pdf file

4
  • What kind of encoding problem is it that out.pdf has? Commented Apr 21, 2015 at 13:53
  • I'd have thought iconv -t latin2 < text | enscript -X latin2 -o - would work, but apparently not. Anybody knows why? Commented Apr 21, 2015 at 14:34
  • 1
    Replying to myself. It's in this FAQ. Probably not worth bothering with enscript and use paps or a2ps or other. Commented Apr 21, 2015 at 14:40
  • 1
    Paps not support headers and footers created with User. Commented Apr 22, 2015 at 10:35

2 Answers 2

6

enscript just does not support Unicode. You need to use a different tool such as paps to convert text to PostScript. With --header option an output .pdf is similar to one produced with enscript:

$ paps text --header | ps2pdf - outheader.pdf 
4
  • Paps not support headers and footers created with User. Commented Apr 22, 2015 at 12:32
  • What is User? Commented Apr 22, 2015 at 12:34
  • I'm a user and I would like created header and footer Commented Apr 22, 2015 at 12:40
  • I'm the author of paps. Please add a detailed feature request in the github repo, and I'll be happy to add this. Commented Jul 29, 2020 at 12:40
5

I have had a better experience with the u2ps program written by Alex Suykov which produces much smaller PDF files using system Unicode fonts. This program is not in Ubuntu or Fedora; you have to compile it yourself. The usage is the same:

$ u2ps text.txt | ps2pdf - text.pdf 

(Compared to u2ps, paps output is huge).

Update, February 2025:

I have written a more extensive post on u2ps and its newer C version here.

1
  • sure, guettli. corrected. Commented Aug 15, 2019 at 12:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.