Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to print unicode encoded file to ps

1,185 views
Skip to first unread message

H.S.

unread,
Mar 15, 2007, 8:20:05 PM3/15/07
to
Hello,

I am trying to print a text file containing different languages
characters, in utf8 encoding, to a ps file. a2ps gives weird characters
in the non-english character's place. Then I discovered u2ps, but it
gives boxes instead with some messages given by the u2ps command:

$> u2ps 20070311-02.tag -o 20070311-02.ps

(gnome-u2ps:10989): GnomePrint-WARNING **: Problem while creating filter
from 'frgba': filter 'frgba' is unknown


While searching google, I notice that there is probably a problem with
the conversion of truetype fonts to ps fonts. Not sure if I am right though.

So, does anyone know what is the state of printing text files in unicode
(or unicode files in general) to postscript files in Linux? And how do I
accomplish the task I described above?

thanks,
->HS


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

li sh

unread,
Mar 15, 2007, 11:30:13 PM3/15/07
to
2007/3/16, H.S. <hs.s...@gmail.com>:

> Hello,
>
> I am trying to print a text file containing different languages
> characters, in utf8 encoding, to a ps file. a2ps gives weird characters
> in the non-english character's place.

I encountered a2ps's embarrassment,too.

> So, does anyone know what is the state of printing text files in unicode
> (or unicode files in general) to postscript files in Linux? And how do I
> accomplish the task I described above?

I use kde. Konqueror(kwite)->file->print->print to file(ps) ,this is
my way. Gnome should also print it to file. Have a try?

--
lish

H.S.

unread,
Mar 15, 2007, 11:40:07 PM3/15/07
to
li sh wrote:
> 2007/3/16, H.S. <hs.s...@gmail.com>:
>> Hello,
>>
>> I am trying to print a text file containing different languages
>> characters, in utf8 encoding, to a ps file. a2ps gives weird characters
>> in the non-english character's place.
>
> I encountered a2ps's embarrassment,too.
>
>> So, does anyone know what is the state of printing text files in unicode
>> (or unicode files in general) to postscript files in Linux? And how do I
>> accomplish the task I described above?
>
> I use kde. Konqueror(kwite)->file->print->print to file(ps) ,this is
> my way. Gnome should also print it to file. Have a try?
>

Interesting, kwrite worked. Gedit, however, did not. The result in that
case was the same as in u2ps, along with the same gnomeprint warning.

So, looks like I have to fire up kwrite just to print a simple text file
to a postscript file.


thanks,
->HS

Jan Willem Stumpel

unread,
Mar 16, 2007, 3:50:16 AM3/16/07
to
H.S. wrote:

> I am trying to print a text file containing different languages
> characters, in utf8 encoding, to a ps file. a2ps gives weird

> characters in the non-english character's place. Then I
> discovered u2ps, but it gives boxes instead with some messages
> given by the u2ps command:

The best program for this is, IMHO, paps. See my utf-8 page
http://www.jw-stumpel.nl/stestu.html#T9.1

Regards, Jan

Douglas Allan Tutty

unread,
Mar 16, 2007, 10:40:05 AM3/16/07
to
On Thu, Mar 15, 2007 at 11:34:47PM -0400, H.S. wrote:
>
> >I use kde. Konqueror(kwite)->file->print->print to file(ps) ,this is
> >my way. Gnome should also print it to file. Have a try?
> >
>
> Interesting, kwrite worked. Gedit, however, did not. The result in that
> case was the same as in u2ps, along with the same gnomeprint warning.
>
> So, looks like I have to fire up kwrite just to print a simple text file
> to a postscript file.

Have you tried LaTex? Sure a .tex file starts with a preamble but you
could have two files head.tex (preamble) and tail.tex (\end{document}).
Then cat head.tex file.txt tail.tex > file.tex, then latex file.tex then
dvips file.dvi. Then you have your file.ps.

Once this all works, write a script that takes your file.txt as an
argument and gives you file.ps. All without X.

Doug.

Jan Willem Stumpel

unread,
Mar 16, 2007, 1:30:17 PM3/16/07
to
Douglas Allan Tutty wrote:

> Have you tried LaTex? Sure a .tex file starts with a preamble
> but you could have two files head.tex (preamble) and tail.tex
> (\end{document}). Then cat head.tex file.txt tail.tex >
> file.tex, then latex file.tex then dvips file.dvi. Then you
> have your file.ps.

> Once this all works, write a script that takes your file.txt as
> an argument and gives you file.ps. All without X.

This will work if you have a Unicode-aware TeX, but why so
complicated? paps (apt-get install paps, in Etch since April last
year) just allows you to say

paps [font options] < test.txt > test.ps.

If you put paps into your lprng input filter, you can just say lpr
test.txt or cat test.txt|lpr (if your basic print system
understands PostScript; normally it does, either natively or
through ghostscript). Completely transparent; Unicode (UTF-8) is
printed just as if you were pushing bytes to an ASCII printer, but
with the whole Unicode charset available. And of course also
without X. Very fast, very neat prints, for Unicode and for ASCII
(because ASCII is a subset of UTF-8), so it can replace your
normal ASCII print setup.

Regards, Jan

H.S.

unread,
Mar 16, 2007, 3:30:14 PM3/16/07
to
Jan Willem Stumpel wrote:
> Douglas Allan Tutty wrote:
>
>> Have you tried LaTex? Sure a .tex file starts with a preamble
>> but you could have two files head.tex (preamble) and tail.tex
>> (\end{document}). Then cat head.tex file.txt tail.tex >
>> file.tex, then latex file.tex then dvips file.dvi. Then you
>> have your file.ps.
>
>> Once this all works, write a script that takes your file.txt as
>> an argument and gives you file.ps. All without X.
>
> This will work if you have a Unicode-aware TeX, but why so
> complicated? paps (apt-get install paps, in Etch since April last
> year) just allows you to say
>
> paps [font options] < test.txt > test.ps.

Worked like a charm!

Thanks a ton,
->HS

H.S.

unread,
Mar 16, 2007, 3:30:14 PM3/16/07
to
Douglas Allan Tutty wrote:
> On Thu, Mar 15, 2007 at 11:34:47PM -0400, H.S. wrote:
> >
>>> I use kde. Konqueror(kwite)->file->print->print to file(ps) ,this is
>>> my way. Gnome should also print it to file. Have a try?
>>>
>> Interesting, kwrite worked. Gedit, however, did not. The result in that
>> case was the same as in u2ps, along with the same gnomeprint warning.
>>
>> So, looks like I have to fire up kwrite just to print a simple text file
>> to a postscript file.
>
> Have you tried LaTex? Sure a .tex file starts with a preamble but you
> could have two files head.tex (preamble) and tail.tex (\end{document}).
> Then cat head.tex file.txt tail.tex > file.tex, then latex file.tex then
> dvips file.dvi. Then you have your file.ps.
>
> Once this all works, write a script that takes your file.txt as an
> argument and gives you file.ps. All without X.
>
> Doug.
>
>

I haven't tried LaTeX yet. But it seems overkill for printing a simple
text file to a ps file. However, I have been playing with the idea of
trying out LaTeX for preparing a document containing international
language characters (I am pretty familiar with LaTeX, but only in
English language bases documents). I will take your hints above and try
it out. For the task at hand through, paps seems promising.

thanks,
->HS

Michelle Konzack

unread,
Mar 27, 2007, 11:40:14 AM3/27/07
to
Am 2007-03-15 23:34:47, schrieb H.S.:
> Interesting, kwrite worked. Gedit, however, did not. The result in that
> case was the same as in u2ps, along with the same gnomeprint warning.
>
> So, looks like I have to fire up kwrite just to print a simple text file
> to a postscript file.

And what do you suggest if one has NOT Gnome and NO KDE?

My problem is that I have several 1000 files which I like
to print from the commandline on a Server whitout using
M$ Windows in my office@gov.

The files are written in over 60 languages and text/plain.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSN LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

signature.pgp

Michelle Konzack

unread,
Mar 27, 2007, 11:40:17 AM3/27/07
to
Hi Doug,

Am 2007-03-16 10:22:16, schrieb Douglas Allan Tutty:
> Have you tried LaTex? Sure a .tex file starts with a preamble but you

> could have two files head.tex (preamble) and tail.tex ( nd{document}).


> Then cat head.tex file.txt tail.tex > file.tex, then latex file.tex then
> dvips file.dvi. Then you have your file.ps.

Nice idea, but LaTeX is to heavy on a server which must print
several 1000 text/plain files...

Do you have a better idea again?

In general I have to print arround 4000-7000 pages per day...

signature.pgp

Michelle Konzack

unread,
Mar 27, 2007, 11:50:18 AM3/27/07
to
Hello Jan,

Am 2007-03-16 18:03:22, schrieb Jan Willem Stumpel:
> This will work if you have a Unicode-aware TeX, but why so
> complicated? paps (apt-get install paps, in Etch since April last
> year) just allows you to say
>
> paps [font options] < test.txt > test.ps.
>
> If you put paps into your lprng input filter, you can just say lpr
> test.txt or cat test.txt|lpr (if your basic print system
> understands PostScript; normally it does, either natively or
> through ghostscript). Completely transparent; Unicode (UTF-8) is
> printed just as if you were pushing bytes to an ASCII printer, but
> with the whole Unicode charset available. And of course also
> without X. Very fast, very neat prints, for Unicode and for ASCII
> (because ASCII is a subset of UTF-8), so it can replace your
> normal ASCII print setup.

This is PERFECTLY what I was serching for my Server...

The Debian GNU/Linux Distribution is realy heavy!!!
Millions/1000 Packages and not realy one know what is in...

signature.pgp

Douglas Allan Tutty

unread,
Mar 31, 2007, 12:30:08 AM3/31/07
to
On Tue, Mar 27, 2007 at 05:07:46PM +0200, Michelle Konzack wrote:
> Hello Jan,
>
> Am 2007-03-16 18:03:22, schrieb Jan Willem Stumpel:
> > This will work if you have a Unicode-aware TeX, but why so
> > complicated? paps (apt-get install paps, in Etch since April last
> > year) just allows you to say
> >
> > paps [font options] < test.txt > test.ps.

> This is PERFECTLY what I was serching for my Server...
>

On that note, please disregard my latest comment. I've been away and am
getting my email gradually. Glad your problem is solved.

Doug.

Douglas Allan Tutty

unread,
Mar 31, 2007, 12:30:09 AM3/31/07
to
On Tue, Mar 27, 2007 at 05:07:25PM +0200, Michelle Konzack wrote:
> Hi Doug,
>
> Am 2007-03-16 10:22:16, schrieb Douglas Allan Tutty:
> > Have you tried LaTex? Sure a .tex file starts with a preamble but you
> > could have two files head.tex (preamble) and tail.tex ( nd{document}).
> > Then cat head.tex file.txt tail.tex > file.tex, then latex file.tex then
> > dvips file.dvi. Then you have your file.ps.
>
> Nice idea, but LaTeX is to heavy on a server which must print
> several 1000 text/plain files...
>
> Do you have a better idea again?
>
> In general I have to print arround 4000-7000 pages per day...
>

Hi Michelle,

I've been away and can't remember the details of the thread so please
forgive any conflicts.

I've only started using LaTex (before that it was Lout) so haven't tried
to latex a large document and time it. What would happen if you took a
dedicated (older?) server whose job it was to take UTF files, and return
ps files? Then the regular print server could take those ps files and
print them.

Is it that LaTex takes too much processing power to generate a document
more beautiful than you need? What else can do it? Can groff handle
UTF-8?

I see it as a variation on the problem of the software takes too much
time. Two options: rewrite the software or give it more hardware.
Treat it like any other compute-bound problem.

7000 pages per day (24 hr) is 5 pages per minute. It takes far less
than a minute for me to LaTex a 30 page document on my Athlon. Tex wont
fit on the drive of my 486 to compare.

An interesting problem. Good luck.

Doug.

JWS

unread,
Apr 2, 2007, 5:40:08 AM4/2/07
to
Michelle Konzack wrote:

> Am 2007-03-16 18:03:22, schrieb Jan Willem Stumpel:

>> paps [font options] < test.txt > test.ps.

> This is PERFECTLY what I was serching for my Server...

Note that the format of the "font options" in paps has changed
between versions 0.6.6 (Etch) and 0.6.7 (Sid). IMHO a bad design
decision by the maker of the program, breaking backwards
compatibility!

In Etch you say e.g.

paps --family Freemono --font_scale 10 < myfile.txt > myfile.ps

In Sid you get the same result with

paps --font "Freemono 10" < myfile.txt > myfile.ps

Regards, Jan


Jeff Zhang

unread,
Apr 2, 2007, 6:20:08 AM4/2/07
to

On 4/2/07, JWS <jstu...@planet.nl> wrote:
Michelle Konzack wrote:

> Am 2007-03-16 18:03:22, schrieb Jan Willem Stumpel:

>> paps [font options] < test.txt   > test.ps.

> This is PERFECTLY what I was serching for my Server...

Note that the format of the "font options" in paps has changed
between versions 0.6.6 (Etch) and 0.6.7 (Sid). IMHO a bad design
decision by the maker of the program, breaking backwards
compatibility!

In Etch you say e.g.

paps --family Freemono --font_scale 10 < myfile.txt > myfile.ps

In Sid you get the same result with

paps --font "Freemono 10" < myfile.txt > myfile.ps

See my utf-8 page: http://www.jw-stumpel.nl/stestu.html#T9.1

If you just want to convert txt into ps then pdf, u2ps from gnome-u2ps will produce better pdf quality with correct embeded font.

Jan Willem Stumpel

unread,
Apr 2, 2007, 10:30:09 AM4/2/07
to
Jeff Zhang wrote:

> If you just want to convert txt into ps then pdf, u2ps from
> gnome-u2ps will produce better pdf quality with correct embeded
> font.

I am sorry, I do not agree. Compared to paps, u2ps is a very poor
program indeed.

- u2ps, unasked, adds a frame around the text and a header. I want
a text printer just to print the text that I feed it. With paps,
adding headers etc. is just an option.

- The margins are wrong (u2ps apparently assumes that I print
using US letter paper, which I don't). The man page offers no
option to cure this.

- u2ps does not seem to use fontconfig (with its automatic font
selection fallback). It is basically a "one font" program. If,
using u2ps mytest.txt, I try to print a page containing many
different languages, box characters, etc., the results are
horribly wrong. By default, Chinese, Korean, Japanese, Arabic,
Greek, Hebrew, Russian, and all the languages of India are
printed only as empty rectangles.

- If I specify the option --gpfamily=Freemono, box characters,
Greek, and Russian are printed OK; Hebrew is printed, but
wrongly; and other scripts not at all (rectangles).

- If I specify the option --gpfamily=Code2000, all languages are
printed, but not in monospace (you lose the "text printing"
feeling; you lose printing boxes made out of utf-8 "box
characters").
Also, the right-to-left languages (Hebrew and Arabic) are
printed the wrong way round, and the "complex text layout"
(Indic) languages are printed wrongly.

- u2ps recognizes tabs, but it does not recognize form feeds
(which you would want a text printer, a drop-in replacement of
an ASCII print system, to do).

- u2ps constantly produces weird warnings like
** (gnome-u2ps:7247): WARNING **: IPP request failed with status
1280

** (gnome-u2ps:7247): WARNING **: IPP request failed with status
1280

(gnome-u2ps:7247): GnomePrint-WARNING **: Problem while creating


filter from 'frgba': filter 'frgba' is unknown

Maybe this would cure itself if I installed full GNOME, but I
don't want to do that.

- I have some minor quibbles too, for instance that u2ps by
default outputs directly to the print queue, instead of to
stdout, as a proper print filter should do. OK, you can
*convert* it to a filter by means of -o /dev/stdout.

paps has none of these disadvantages. I have not found *one*
aspect in which u2ps is better than paps. Also as to print quality
(for the characters that *do* get printed) I think u2ps is in no
way superior to paps. The paps output can easily be pdf'd by means
of ps2pdf.

Sorry to be so harsh, but I think I gave arguments.

Jeff Zhang

unread,
Apr 2, 2007, 11:50:06 AM4/2/07
to
Yes, paps is better than u2ps in function(sure, a2ps will be the best if not for unicode), however, the pdf produced after ps2pdf is not the case in my own experience. As u2ps can produce TrueType fonts embeded pdf file while paps not.

with simple unicode encoding file(test.txt), like:
chinese 中文

then produce with:
u2ps -X utf8 --gpfamily="Sans 12" test.txt -o u2ps.ps
paps --font "Sans 12" < test.txt >paps.ps
ps2pdf u2ps.ps
ps2pdf paps.ps

then run:
% pdffonts u2ps.pdf                           
name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
GHTXAC+GnomeUni-MicrosoftYaHei_005   TrueType     yes yes no      14  0
MGWIUQ+GnomeUni-MicrosoftYaHei_007   TrueType     yes yes no      12  0
SPULKW+GnomeUni-MicrosoftYaHei_004   TrueType     yes yes no      10  0
EEOVEQ+GnomeUni-MicrosoftYaHei       TrueType     yes yes no       8  0
% pdffonts paps.pdf
name                                 type         emb sub uni object ID
------------------------------------ ------------ --- --- --- ---------
Helvetica                            Type 1       no  no  no       8  0

JWS

unread,
Apr 2, 2007, 1:40:11 PM4/2/07
to
Jeff Zhang wrote:

> [Try it] with simple unicode encoding file (test.txt), like:

> chinese 中文

> then produce with:
> u2ps -X utf8 --gpfamily="Sans 12" test.txt -o u2ps.ps
> paps --font "Sans 12" < test.txt >paps.ps

It must have something to do with installed fonts. I repeated your
experiments exactly, but when viewing the .ps files with gv:

- u2ps.ps had rectangles instead of 中文
- paps.ps displayed 中文 correctly.

Maybe this is because I do not have the Chinese fonts that you
mentioned (like GnomeUni-MicrosoftYaHei_005) installed. Because of
fontconfig, this does not matter with paps; it just finds another
font which has the "中" and "文" characters. But u2ps cannot.

I hope the unicode characters in this message make it to the list..

Michelle Konzack

unread,
Apr 18, 2007, 7:52:13 PM4/18/07
to
Am 2007-04-02 18:18:07, schrieb Jeff Zhang:
> If you just want to convert txt into ps then pdf, u2ps from gnome-u2ps will
> produce better pdf quality with correct embeded font.

But can this run on a server which produce over 4000 PDF-Pages
per day? I mean in a working day of around 8-10 hours not 24.

signature.pgp
0 new messages