2015-02-24 14:36 GMT+01:00 Pavel <pavel....@gmail.com>:

> Really thanks José,
> your "labels" app help me with understanding fpdf. My apps is working now.
>


You're welcome

> "Little" problem is unicode characters. I tried examples from fpdf wiki
> pages, but without success.
> Fortunately all dynamic fields on our ID cars is numbers and characters
> without accent.
>

Yes, all of us who don't live in english spoken countries share the same
problem.
There are two solutions for this issue, depending on the charset you need.

The easy one is executing:

    import sys
    reload(sys)
    sys.setdefaultencoding("latin-1")

In the function you are generating the pdf. This works for me with accents
or spanish ñ.


But, if there are some chars not available in latin-1 encoding (like the
european currency €) the second solution is loading a true type font:

As an example:
    import sys

    reload(sys)
    sys.setdefaultencoding("utf-8")

    pdf.add_font('DejaVu', '',os.path.join(request.folder,'static',
'DejaVuSansCondensed.ttf'), uni=True)

This should work like a charm (if you leave the file
DejaVuSansCondensed.ttf  in the static folder of your application)


Regards
José L.



>
> Thanks
>
>  --
> 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.
>

-- 
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