wxHtmlEasyPrinting, Postscript and Encoding
David Solbach
d at vidsolbach.de
Sun Mar 2 03:51:57 PST 2008
Hi there,
I'm pretty desperate with an encoding problem here.
I try to print an html file using the wxHtmlEasyPrinting class. The print
preview looks fine and all german umlauts and the euro sign look nice.
However, if I print the postscript to a file or a printer, the umlauts and
special characters get screwed up (ä becomes ä, which seems to be the case
if UTF-8 is interpreted as ISO-8859-1).
My test-html looks like this (encoded on disk in UTF-8):
---
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
an ae (html notation): ä<br>
an ue (html notation): ü<br>
an euro sign (htmlnotation): €<br>
an ae: ä<br>
an ue: ü<br>
an euro sign: €<br>
</html>
---
I read this file from Disk to a wxString using wxTextFile and then print it
with wxHtmlEasyPrinting::PreviewText(). The resulting is attached.
(as you can see, the ä is written as \303\244 which looks like UTF-8 in its
octal representation, but the postscript file itself states, that it's
in "/ISOLatin1Encoding" encoding?)
My Platform is linux (Kubuntu 7.10) and I use wxWidgets in version 2.8. The
system's standard encoding should be UTF-8. And I use the -DwxUSE_UNICODE
define.
Here is the complete compiler command line:
/usr/bin/c++ -I/usr/lib/wx/include/gtk2-unicode-debug-2.8
-I/usr/include/wx-2.8 -pthread
-g -isystem /usr/lib/wx/include/gtk2-unicode-debug-2.8
-isystem /usr/include/wx-2.8
-isystem /home/david/Projects/hotelphone/-pthread
-I/home/david/Projects/hotelphone/mainapp/../include
-I/home/david/Projects/hotelphone/mainapp/../libcsta
-I/home/david/Projects/hotelphone/mainapp/../libsystem
-DwxUSE_UNICODE -D_DEBUG -D_FILE_OFFSET_BITS=64
-D_LARGE_FILES -D__WXDEBUG__ -D__WXGTK__ -pthread -o
mainapp/CMakeFiles/hotelphone.dir/receiptprintout.o
-c /home/david/Projects/hotelphone/mainapp/receiptprintout.cpp
Please, help, Anyone? ;)
Cheers,
David
---
%!PS-Adobe-2.0
%%Title: Drucken von Printing
%%Creator: wxWidgets PostScript renderer
%%CreationDate: Sun Mar 2 12:20:55 2008
%%Orientation: Portrait
%%DocumentPaperSizes: A4
%%EndComments
%%BeginProlog
/conicto {
/to_y exch def
/to_x exch def
/conic_cntrl_y exch def
/conic_cntrl_x exch def
currentpoint
/p0_y exch def
/p0_x exch def
/p1_x p0_x conic_cntrl_x p0_x sub 2 3 div mul add def
/p1_y p0_y conic_cntrl_y p0_y sub 2 3 div mul add def
/p2_x p1_x to_x p0_x sub 1 3 div mul add def
/p2_y p1_y to_y p0_y sub 1 3 div mul add def
p1_x p1_y p2_x p2_y to_x to_y curveto
} bind def
/ellipsedict 8 dict def
ellipsedict /mtrx matrix put
/ellipse {
ellipsedict begin
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
xrad yrad scale
0 0 1 startangle endangle arc
savematrix setmatrix
end
} def
/ellipticarcdict 8 dict def
ellipticarcdict /mtrx matrix put
/ellipticarc
{ ellipticarcdict begin
/do_fill exch def
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y translate
xrad yrad scale
do_fill { 0 0 moveto } if
0 0 1 startangle endangle arc
savematrix setmatrix
do_fill { fill }{ stroke } ifelse
end
} def
% define 'colorimage' if it isn't defined
% ('colortogray' and 'mergeprocs' come from xwd2ps
% via xgrab)
/colorimage where % do we know about 'colorimage'?
{ pop } % yes: pop off the 'dict' returned
{ % no: define one
/colortogray { % define an RGB->I function
/rgbdata exch store % call input 'rgbdata'
rgbdata length 3 idiv
/npixls exch store
/rgbindx 0 store
0 1 npixls 1 sub {
grays exch
rgbdata rgbindx get 20 mul % Red
rgbdata rgbindx 1 add get 32 mul % Green
rgbdata rgbindx 2 add get 12 mul % Blue
add add 64 idiv % I = .5G + .31R + .18B
put
/rgbindx rgbindx 3 add store
} for
grays 0 npixls getinterval
} bind def
% Utility procedure for colorimage operator.
% This procedure takes two procedures off the
% stack and merges them into a single procedure.
/mergeprocs { % def
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/colorimage { % def
pop pop % remove 'false 3' operands
{colortogray} mergeprocs
image
} bind def
} ifelse % end of 'false' case
/reencodeISO {
dup dup findfont dup length dict begin
{ 1 index /FID ne { def }{ pop pop } ifelse } forall
/Encoding ISOLatin1Encoding def
currentdict end definefont
} def
/ISOLatin1Encoding [
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
/parenleft/parenright/asterisk/plus/comma/minus/period/slash
/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve
/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut
/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar
/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
/guillemotright/onequarter/onehalf/threequarters/questiondown
/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
/yacute/thorn/ydieresis
] def
/DrawSplineSection {
/y3 exch def
/x3 exch def
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
/xa x1 x2 x1 sub 0.666667 mul add def
/ya y1 y2 y1 sub 0.666667 mul add def
/xb x3 x2 x3 sub 0.666667 mul add def
/yb y3 y2 y3 sub 0.666667 mul add def
x1 y1 lineto
xa ya xb yb x3 y3 curveto
} def
%%EndProlog
1.000000 setlinewidth
%%Page: 1
1.00000000 1.00000000 scale
0 0 translate
1.00000000 1.00000000 1.00000000 setrgbcolor
gsave
newpath
70 771 moveto
523 771 lineto
523 715 lineto
70 715 lineto
closepath clip newpath
/Helvetica reencodeISO def
/Helvetica findfont
8.000000 scalefont setfont
0.00000000 0.00000000 0.00000000 setrgbcolor
70 764 moveto
(an ) show
82 764 moveto
(ae ) show
94 764 moveto
(\(html ) show
118 764 moveto
(notation\): ) show
162 764 moveto
(\303\244) show
70 756 moveto
(an ) show
82 756 moveto
(ue ) show
94 756 moveto
(\(html ) show
118 756 moveto
(notation\): ) show
162 756 moveto
(\303\274) show
70 748 moveto
(an ) show
82 748 moveto
(euro ) show
102 748 moveto
(sign ) show
122 748 moveto
(\(htmlnotation\): ) show
186 748 moveto
(\342\202\254) show
70 740 moveto
(an ) show
82 740 moveto
(ae: ) show
98 740 moveto
(\303\244) show
70 732 moveto
(an ) show
82 732 moveto
(ue: ) show
98 732 moveto
(\303\274) show
70 724 moveto
(an ) show
82 724 moveto
(euro ) show
102 724 moveto
(sign: ) show
126 724 moveto
(\342\202\254) show
grestore
showpage
---
More information about the wx-users
mailing list