Postscript printer question
Tim Writer
tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Tue Mar 14 00:52:40 UTC 2006
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org (Lennart Sorensen) writes:
> On Mon, Mar 13, 2006 at 11:40:39AM -0500, Madison Kelly wrote:
> > Hi all,
> >
> > I've got a bit of a problem... I've got a perl script that looks at a
> > PS file that I print from OpenOffice2.
> >
> > The program (which I can't modify) reads the postscript and looks for
> > '~' (tilde) and substitutes in values where they are found. I have tried
> > creating a printer (the recommended printer is the Apple LaserWriter NT)
> > and told to print in PostScript level 1. Then I print a given document
> > to a file using this (dummy) printer.
> >
> > The problem is that when I look at the resulting PS file instead of
> > getting '~' where appropriate I am getting (the ASCII?) '<7E>' instead.
> > Has anyone run into this before? If so, any idea how to tell it to print
> > the tilde instead of the ASCII?
> >
> > As an aside, when the same printer in PS level 1 is used on MS'
> > Office the result is the tilde and I need to mimic this behavior.
>
> Well after a quick look, if I did something like:
>
> echo "abc ~ 123" | a2ps -o a2pstemp.ps
>
> I get something which contains the code:
> x0 y0 moveto
> (abc ~ 123) p n
>
> Which seems reasonable.
>
> Do the same from open office with print to file and you get:
> 162 131 moveto
> 0 setgray
> (TimesNewRomanPSMTHGSet1) cvn findfont 50 -50 matrix scale makefont
> setfont
> <616263207E20313233>
>
> Where the stuff in <...> is the hex codes for the stuff that was ascii
> in (...) above.
>
> Of course this probably means it is reasonable to look for <...> lines
> in the output from OOo parsing 2 characters at a time, looking for 7E
> and replacing it with the hex encoding of the desired string, which
> before you just had to look for ~ in (...) lines and replace that.
The PostScript Red Book has this to say:
A hexadecimal string consists of a sequence of hexadecimal
digits (09 and either AF or af) enclosed within < and >. Each
pair of hexadecimal digits defines one character of the
string. White-space characters are ignored. If a hexadecimal
string contains characters outside the allowed character set,
a syntaxerror occurs. Hexadecimal strings are useful for
including arbitrary binary data as literal text.
So, while this is legal behaviour on the part of OOo, I would argue that it
departs from the intent as your example uses plain text.
In case you decide to implement a scanner, be aware of this:
If the final digit of a given hexadecimal string is missing in
other words, if there is an odd number of digits, the final
digit is assumed to be 0. For example, <901fa3> is a
3-character string containing the characters whose hexadecimal
codes are 90, 1f, and a3, but <901fa> is a 3-character string
containing the characters whose hexadecimal codes are 90, 1f,
and a0.
There's no reason for OOo to escape ~ as, according to the Red Book, only
(, ), <, >, [, ], {, }, /, and % are special. Having said that, PostScript
uses <~ and ~> as delimiters for base 85 strings.
> Or you can try and figure out how to make OOo not use the hex encoding,
> although I suspect it has to do with unicode and other multilanguage
> support and the fonts it uses, where perhaps on windows you are getting
> a simpler ascii only version. Even setting OOo to postscript level 1
> did nothing to change the output.
It could be as simple as playing with your LANG or LOCALE environment
variables.
--
tim writer <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> starnix inc.
647.722.5301 toronto, ontario, canada
http://www.starnix.com professional linux services & products
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list