I am not having that problem when testing your code with pyfpdf 1.7.2, 
using the same font.  I noticed web2py 2.12.3 is still using pyfpdf 1.7.1.  
I recommend temporarily replacing pyfpdf folder with new version an try 
again.

On Saturday, November 28, 2015 at 1:46:12 PM UTC-4, mweissen wrote:
>
> Hi, I have tried again to use fpdf.
>
> *1st try:*
>
> from gluon.contrib.fpdf import FPDF
>
> def test():
>     pdf = FPDF('P', 'mm', 'A4')
>     pdf.add_page()
>     pdf.set_font('Arial', 'B', 16)
>     pdf.cell(40,10,'Hello World')    
>     response.headers['Content-Type'] = 'application/pdf'    
>     return XML(pdf.output('', 'S'))
>
>
> Ok, that's simple and it works fine.
>
> *2nd try:*
>
> Now I want to use the unicode version.
> There is a example: https://code.google.com/p/pyfpdf/wiki/Unicode:
>
> *Before you can use UTF-8, you have to install at least one Unicode font 
> in the font directory (or system font folder).*
>
>
> But there is no font directory in fpdf!
>
> It would be nice to have a complete example how to use fpdf in web2py!
>
> After some trials I had to copy the *font directory* containing a lot of 
> "DejaVu*"-files to the gluon/contrib/fpdf directory. 
>
> The structure is: gluon/contrib/fpdf/font
>
>
> ​from gluon.contrib.fpdf import FPDF
>
> def test():
>     pdf = FPDF('P', 'mm', 'A4')
>     pdf.add_page()
>     pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
>     pdf.set_font('DejaVu', '', 14)
>     pdf.cell(40,10,'Hello World  äöü€')
>     
>     response.headers['Content-Type'] = 'application/pdf'    
>     return XML(pdf.output('', 'S'))
>
>
> ​And now I get an error message:
>
> ​<type 'exceptions.ValueError'> could not convert string to float
>
> Version
> web2py™Version 2.12.3-stable+timestamp.2015.08.19.00.18.03PythonPython 
> 2.7.6: /usr/local/bin/python (prefix: /usr)
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "/home/www-data/web2py/gluon/restricted.py", line 227, in restricted
>     exec ccode in environment
>   File "/home/www-data/web2py/applications/m_abschluss/controllers/test.py" 
> <https://www.sinfs.at/admin/default/edit/m_abschluss/controllers/test.py>, 
> line 54, in <module>
>   File "/home/www-data/web2py/gluon/globals.py", line 412, in <lambda>
>     self._caller = lambda f: f()
>   File "/home/www-data/web2py/applications/m_abschluss/controllers/test.py" 
> <https://www.sinfs.at/admin/default/edit/m_abschluss/controllers/test.py>, 
> line 26, in test
>     pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True)
>   File "/home/www-data/web2py/gluon/contrib/fpdf/fpdf.py", line 432, in 
> add_font
>     font_dict = pickle.load(fh)
> ValueError: could not convert string to float
>
>
> ​
> ​What is the right way to use fpdf with the whole unicode character set 
>  in web2py?​
>
> ​Regards, Martin​
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to