I am trying to print a large quantity (several megabytes) of UTF-8 encoded text which consists of Chinese and Latin characters (and maybe a sprinkling of others). I would like to print it in several columns per page, in a very small, condensed font, preferably with control over line spacing. I'd quite like inter-column lines, but I can live without them. The aim is to print to PDF for transfer, as well as to paper.

I have tried enscript and a2ps, but neither of these support Unicode.

I have also tried paps, but this produces bitmapped outputs which cannot be PDF'd effectively, and also look terrible.

Is there a modern way to print UTF-8 text like this without resorting to something like constructing it manually in Python?

  • What OS are you running? Have you tried opening them in a text editor and printing to PDF there? If that works, we can figure out how to automate. LaTeX should of course also be able to do it but I'd need an example of the files in question to provide you with a proper answer. – terdon Nov 20 '13 at 0:44
  • OS is Lubuntu 13.04. I know I can print from a text editor, but if I do that, I'll have to print thousands of pages. I'll try to provide something sensible looking if you think that will help, but it's basically screeds and screeds of text in Latin and Chinese with a few "special" characters like "#" and numbers. – Inductiveload Nov 20 '13 at 10:14

Cedilla is a text-to-postscript converter, similar to enscript and a2ps, with good Unicode support but a lot fewer configuration possibilities. I don't think Cedilla can to multi-column.

If you want fine control over the formatting, you can use LaTeX. LaTeX's support for going beyond 8 bits is a bit problematic, but tools now exist to typeset Chinese fairly painlessly. Here's some untested code, inspired by How does one type Chinese in LaTeX? and Include data from a .txt on our sister site about TeX. You can customize the appearance of the text by changing the options passed to \VerbatimInput from the fancyvrb package.

cat <<'EOF' >driver.tex
pdflatex driver.tex
  • My text has things like "###" in it which LaTeX chokes on - is there a way to escape the \input{} text? The verbatim environment won't expand the \input directive. – Inductiveload Nov 20 '13 at 10:20
  • @Inductiveload See my edit. I've tested a version of that with only Latin-type characters (but going beyond ASCII), I hope there won't be any nasty interactions with Chinese. – Gilles 'SO- stop being evil' Nov 20 '13 at 10:48
  • That seems to make some sense of it, but the text won't wrap inside the \VerbatimInput, which is important as there are long and short lines in the text. Maybe a listing environment of some sort? – Inductiveload Nov 20 '13 at 15:46
  • Since this is getting rather TeX'y and not Unix'y, TeX-based cross-post at TeX SE here. – Inductiveload Nov 20 '13 at 16:12
  • This is the way I finally did it, but the TeX is a bit different, and used XeLaTeX to help with the Unicode. I used some Perl munging to escape special chars and insert artificial line breaks to allow tight wrapping of bizarre strings of text without whitespace. See the TeX SE question for more details. – Inductiveload Nov 21 '13 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.