> 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 “α”) 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 * * 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?* 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? (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*. > (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 Kind regards, Martin -- --- 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.