support for utf-8 encoding with lpr
Solution 1
The same can be done with paps;
#!/bin/bash
#This script converts UTF-8 txt to postscript
paps | lpr
Sometimes you need to specify the prinqueue;
#!/bin/bash
# This script converts UTF-8 txt to postscript
paps | lpr -P lj
Paps does a much better job then cups' texttops.
Solution 2
I don't know if you consider HPLIP an external dependency, but here is the official driver recommendation directly from CUPS.
and Here is the Package info in the Debian Repo:HPLIPS
As Thushi states your system doesn't know how to rasterize the document without using a tool like paps. Installing the hplip package and configuring it at http://localhost:631
to use the recommended driver will solve your issue. For more info, see the SystemPrinting entry at the DebianWiki
Related videos on Youtube
user001
Updated on September 18, 2022Comments
-
user001 over 1 year
While trying to send a text file to the printer via
lpr
fromxterm
, the content was corrupted beyond recognition, the cause of which was ultimately traced to the encoding of the file. If I instead process the text withiconv
(e.g.,iconv -f utf-8 -t ascii//TRANSLIT
), then the file is printed normally. Another suggestion I came across is setting the document format (e.g.,lpr -o document-format=text/utf8
), but this returns the errorlpr: Unsupported document-format "text/utf8"
. I could always alias thelpr
command to include processing byiconv
, but is there a more general way for native utf-8 support in theCUPS
/lpr
system?Edit: My OS is Debian 8 and my window manager is
openbox
(no desktop environment). I can print this file without any problem from MacOS X as well as from a Debian7/Gnome3 system.From my current system, I should point out that even after changing character encoding from UTF-8 to ASCII, the newline characters are not respected by
lpr
, so the lines are concatenated together and printed until the paper margin is reached. After recoding and transliteration withiconv
on MacOS X, the printing still works normally (so the newline issue is also specific to my current system).-
Netch almost 10 yearsI haven't deep CUPS knowledge but it definitely should include rules how to detect document type (with MIME type on output) and how to translate any for target printer, this includes rasterisation, forming Postscript or PCL file, etc. Could you please specify your printer type? Did you try
a2ps
? What encoding is really used on output, when you try utf-8? (I guess it'siso-8859-1
) -
Netch almost 10 yearsSeems that applied encoding is iso-8859-1. You can easily check this using its table. Some searching suggests calling as
lpr -o document-format='text/plain;charset=utf-8'
will be enough to print as you want, but this doesn't change your CUPS installation default which seems obsolete.
-
-
user001 almost 10 yearsThanks very much for your reply. I'm aware of
paps
and wanted to know if there was a possibility of native support withinCUPS
so that external dependencies needn't be invoked. -
user001 over 9 yearsThanks. I already have the latest version of HPLIP on my system. I tried to find where one can specify this in
http://localhost:631
but I could not find anything about driver selection. -
eyoung100 over 9 yearsRead Section 4