Sorry for being so late.
I have put it all in an issue on the pyfpdf page.
Regards, Martin


2013/2/19 Mariano Reingart <reing...@gmail.com>

> On Tue, Feb 19, 2013 at 6:29 PM, Martin Weissenboeck <mweis...@gmail.com>
> wrote:
> >> The result: the “ά” is not shown
> >>
> >> > That is interesting, because the accent is important in the Greek
> >> > language
> >> > and it could change the meaning of a word..“ά” is replaced by a black
> >> > square. Maybe the reportlab font does not know the Unicode character
> >> > U+03AC?
> >>
> >> Sorry, I cannot help you with reportlab, it is a complex software piece.
> >> In fact, that's why I don't use reportlab and decided to go with pyfpdf
> >> :-)
> >
> >
> > (a) I'll try it later.
> >
> >>
> >> > (4) in def listing():
> >> >
> >> > line 142:
> >> >     response.title = "web2py sample listing with äö€ß Χανιά"
> >> >
> >> > listing.html is ok
> >> > listing.pdf:
> >> >
> >> > “web2py sample listing with äö€ß Χανιά”
> >> >
> >> >
> >> > I think there is a problem. It seems, that HTML-texts with no-latin-1
> >> > characters (like “äö€ß” or “Χανιά") or HTML-equivants (like “&alpha;”)
> >> > do
> >> > not work.
> >>
> >> Yes, you need to set a unicode font like in get_me_a_unicode_pyfpdf()
> >> to get non-latin1 support.
> >>
> >> It's a bit tricky, you could do the following:
> >>
> >> # add the font to the pdf document:
> >> pdf.add_font('DejaVu', '', os.path.join(request.folder, "private",
> >> "font", 'DejaVuSans.ttf'), uni=True)
> >>
> >> # create the basic html parser:
> >> h2p = HTML2FPDF(pdf, image_map)
> >>
> >> # update the supported font list:
> >> h2p.font_list = list(h2p.font_list) + ['DejaVu']
> >>
> >> # convert basic html to pdf:
> >> h2p.feed(text)
> >>
> >> Then, in your html text, you have to specify the font tag:
> >> <font face="DejaVu"> .... </font>
> >>
> > (b) I have written a new function:
> >
> > from reportlab.platypus import *
> > from reportlab.lib.styles import getSampleStyleSheet
> > from reportlab.rl_config import defaultPageSize
> > from reportlab.lib.units import inch, mm
> > from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
> > from reportlab.lib import colors
> > from uuid import uuid4
> > from cgi import escape
> > import os
> > # maybe not all imports are necessary
> >
> > def report4():
> >     from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> >     from gluon.contrib.pyfpdf.html import HTML2FPDF
> >
> >     text = u"<font face='DejaVu'>abc<br/>äöü</font>"
> >     text2 = u"€" # does not work
>
> did you triy u"<font face='DejaVu'>abc<br/>€</font>"?
>
> >     text3 = u"Χανιά" # does'n work
> >
> >     pdf=FPDF()
> >
> >
> >     pdf.add_font('DejaVu', '', os.path.join(request.folder, "private",
> > "font", 'DejaVuSans.ttf'), uni=True)
> >     pdf.set_font('DejaVu','',12)
> >
> >
> >     # create the basic html parser:
> >     # h2p = HTML2FPDF(pdf, image_map) # what is image map?
>
> image_map is something introduced by Massimo :-)
>
> >     h2p = HTML2FPDF(pdf)
> >
> >     h2p.font_list = list(h2p.font_list) + ['DejaVu']
> >     pdf.add_page()
> >     h2p.feed(text)
> >
> >     response.headers['Content-Type']='application/pdf'
> >     return pdf.output(dest='S')
> >
> > Result: as expected, with or without <face... >
> > But: again it's only possible to use Latin-1 characters. What is wrong?
>
> I'ld have to debug the html generation, it should respect the <font
> face=""> but ...
> If you can, please send me the .py so it easier to debug.
>
> > (c) I think there is another problem:
> > The file "DejaVuSans.pkl" contains an absolute file path, e.g.
> >
> > line 4:
> >
> S'D:\\dropbox\\web2py\\applications\\fpdf17utest\\private\\font\\DejaVuSans.ttf'
> >
> > I have not tried it, but I think, therefore this application will not be
> > portable.
>
> I've noticed this too.
> The pkl file is a temporary file (in python pickle format) just to
> speed up ttf handling, it should be generated on each install.
> Anyway it is not a major issue, it could be removed and it will be
> generated automatically with the new path (I think this should be done
> in case of error, instead of throwing an exception about the absolute
> path).
>
> If you can please fill an issue in the fpdf project site so it is not lost.
> The change should be trivial to support relative paths, but I'm afraid
> I could have no time right now.
>
> >
> >    > (6) Some typos:
> >>
> >> >
> >> > line 90:
> >> >
> >> > "example to generate a pdf based on basic html (use
> http:/.../report.pdf
> >> > download the pdf)"
> >> >
> >> >
> >> > line 218:
> >> >
> >> > "example to generate an invoice based on a generic pdf template"
> >> >
> >>
> >> Thanks, could you send me the final file fixed, or fill an issue?
> >> (some text are truncated in the email)
> >>
> > ok
>
> Thanks
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to