6

I have a troff document (manpage) with UTF-8 characters and I am trying to convert it to a PDF. However, when using the -Tpdf option, the PDF generated does not show the correct characters. This is the command I am using:

groff -k -Tutf-8 -pet -Tpdf -mandoc filename.1 > filename.pdf

Examples of what goes wrong:

"Používá" becomes "Pou3⁄4ívá"
"překladač" becomes "pøekladaè"
"prováděných" becomes "provádìných"
"rozšířením" becomes "roz1íøením"

How to do it correctly?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
magnusi
  • 61
  • 2
  • 1
    Are you sure you want `-Tutf-8`? From a glance at the manual, it seems like your two `-T` options might be conflicting, and `-D` is used to select a charset – Fox Apr 25 '17 at 20:13
  • Ah, sorry, I am not sure, I was just already very desparate. Using -D utf-8 makes the problematic characters disappear completely, resulting in 'can't find special character' warnings – magnusi Apr 25 '17 at 21:34
  • 1
  • I'm testing things now. Interestingly, if I use `-D utf-8` or `-K utf-8` along with `-T utf-8`, I can see the Czech symbols, but when I change `-T utf-8` to `-T ps` or `-T pdf` the problem arises. So `grotty` acts fine with Unicode, but `grops` and `gropdf` are having trouble – Fox Apr 25 '17 at 22:38
  • 1
    See also [The Linux Documentation Project](http://www.tldp.org/HOWTO/Unicode-HOWTO-5.html) stating that `groff -Tps` is only capable of outputting the Unicode characters that "PostScript supports by itself" (though it doesn't specify which version of `groff`). Since PDF is just compiled PostScript, this is probably the issue. – Fox Apr 25 '17 at 23:10

1 Answers1

3

The following convoluted way works:

groff -Kutf8 -Tdvi -mec -ms test.ms > test.dvi
dvipdfm -cz 9 test.dvi
open test.pdf

Via the [Groff] latin2 polish special characters thread on lists.gnu.org.

  • For dvipdfm (or just dvipdf on some distros) you will need a texlive-basic (texlive-bin in case of Arch linux) package. dvipdfm alias calls gs and dvips which is not installed by Ghostscript.. You will need texlive for the dvips. – msam Mar 14 '21 at 00:21