Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text to pdf with utf8 encoding (alternative to a2ps)

The programm a2ps does not support utf-8. At least my version does only support the latin-X encodings:

a2ps --list=encoding

Version:

GNU a2ps 4.14

How can I convert a simple utf-8 text to postscript or pdf?

like image 880
guettli Avatar asked Jul 17 '14 04:07

guettli


People also ask

Is UTF-8 same as UTF-8?

UTF-8 is a valid IANA character set name, whereas utf8 is not. It's not even a valid alias. it refers to an implementation-provided locale, where settings of language, territory, and codeset are implementation-defined.

What is UTF-8 encoded text?

UTF-8 is a Unicode character encoding method. This means that UTF-8 takes the code point for a given Unicode character and translates it into a string of binary. It also does the reverse, reading in binary digits and converting them back to characters.


2 Answers

If what you actually want is to use a2ps or enscript (which is a similar tool), and if your single need is to use them with some UTF-8 document, you only have to convert your document to ISO-8859-1 or some supported encoding. Various tools allow this. For instance, here is a workflow for enscript (but you can surely do the same with a2ps):

cat document.txt | iconv -c -f utf-8 -t ISO-8859-1 | enscript -o document.ps

But you may lose some characters during the conversion because such encodings have a smaller range than UTF-8.

On the other hand, if UTF-8 is a requirement, you may rather have to look for some recent tool allowing to convert UTF-8 to PDF. I wrote myself a Python program called txt2pdf; you may find it here. Have also a look at tools like pandoc, gimli, rst2pdf or wkhtmltopdf.

like image 145
Thomas Baruchel Avatar answered Oct 18 '22 13:10

Thomas Baruchel


Use paps! For instance I use it as follow:

paps --font="Monospace 10" input.txt > output.ps  

and I have no problem with utf encoding. If you need a pdf file then

pdf2ps output.ps 
like image 21
jimifiki Avatar answered Oct 18 '22 11:10

jimifiki