Sorry, I misread the email.

Unicode fonts were not supported in html2pdf.

I've made a change to allow them, please update html.py:

https://pyfpdf.googlecode.com/hg/fpdf/html.py

Then, you need to load a ttf unicode font, and then pass it in <font>
face attribute:

pdf=MyFPDF()
# add utf8 font
pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
# first page:
pdf.add_page()
pdf.write_html(u"<font face='DejaVu'>Ąžuolas</font>")

For more info and complete code, see:

https://code.google.com/p/pyfpdf/wiki/Web2Py

Let me know if that works so I can update the docs and web2py contrib version

Best regards
Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Fri, Apr 26, 2013 at 11:45 PM, Mariano Reingart <reing...@gmail.com> wrote:
> On Fri, Apr 26, 2013 at 11:42 PM, Mariano Reingart <reing...@gmail.com> wrote:
>> On Fri, Apr 26, 2013 at 6:34 PM, Jonathan Lundell <jlund...@pobox.com> wrote:
>>> On 26 Apr 2013, at 1:17 PM, Jurgis Pralgauskis
>>> <jurgis.pralgaus...@gmail.com> wrote:
>>>
>>> ok, SOLVED ttf issue for  unicode example
>>> http://code.google.com/p/pyfpdf/wiki/Unicode
>>> just needed to create directory    gluon > contrib > fpdf > font
>>> and place needed ttf files insited it :)
>>> then pdf.write(8, u"Ąžuolas")  works fine
>>>
>>>
>>> The fpdf logic uses utf8 for fonts it sees as UTF-based, otherwise latin-1.
>>> It looks to me as though either it isn't recognizing your fonts as UTF, or
>>> there's some overlooked case that it's making a mistake with. Have a look at
>>> FPDF.set_font:
>>>
>>>         self.unifontsubset = (self.fonts[fontkey]['type'] == 'TTF')
>>>
>>> ...and make sure it's getting set.
>>>
>>
>> Yes, as Jhonatan saids, FPDF (and the PDF standard, BTW) only support
>> latin1 characters for standard font.
>>
>> If you need utf8 characters, you need to embeed a T
>
> You need to embed a UTF8 TTF font, for example:
>
> # Add a DejaVu Unicode font (uses UTF-8)
> # Supports more than 200 languages. For a coverage status see:
> # 
> http://dejavu.svn.sourceforge.net/viewvc/dejavu/trunk/dejavu-fonts/langcover.txt
> pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
>
> (sorry, the previous message was sent incomplete)
>
> I'll try to enhance the docs about this, thank for reporting the issue
>
> Best regards
>
> 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.


Reply via email to