On Mon, Jan 10, 2011 at 09:27, zusfed <musaf...@gmail.com> wrote:
> is there a way to show these utf-8
> characters in pdf?
> i live in turkey, so almost every description fields on my application
> have turkish characters. i googled a bit, searched geraldo docs but no
> luck .
I think you will have help here, because geraldo is a brazilian
project and I doubt that Marinho (the maintainer) used something like
latin-1 encoding to print out PDF with non-ASCII characters.
Do you use the prefix 'u' in your unicode strings? Example:
# -*- coding: utf-8 -*-
my_turkish_string = u"porção de coração com lingüiça"
Regards,
--
Danilo Cabello
Bottom-poster maniac.
class cihazlar(models.Model):
sno = models.IntegerField()
aciklama = models.CharField(max_length=100)
.
.
.
def __unicode__(self):
return self.aciklama
def report_go(request):
resp = HttpResponse(mimetype='application/pdf')
xcihaz = cihazlar.objects.filter()
report = CihazRapor(queryset=xcihaz)
report.generate_by(PDFGenerator, filename=resp)
return resp
class CihazRapor(Report):
title = 'ccc'
author = 'foo'
page_size = landscape(A4)
margin_left = 2*cm
margin_top = 0.5*cm
margin_right = 0.5*cm
margin_bottom = 0.5*cm
class band_detail(ReportBand):
height = 0.5*cm
elements=(
ObjectValue(attribute_name='id', left=0.5*cm),
ObjectValue(attribute_name='aciklama', left=3*cm,width=10*cm,get_value=lambda instance: 'desc: ' + (instance.aciklama) ,style={'fontName': 'helvetica', 'fontSize': 8})
)
u"some_turkish_char_here"
u'\u0131'
'\xc4\x9f'
--
Você está recebendo esta mensagem porque se inscreveu no grupo "geraldo-users" dos Grupos do Google.
Para postar neste grupo, envie um e-mail para gerald...@googlegroups.com.
Para cancelar a inscrição nesse grupo, envie um e-mail para geraldo-user...@googlegroups.com.
Para obter mais opções, visite esse grupo em http://groups.google.com/group/geraldo-users?hl=pt-BR.
On Mon, Jan 10, 2011 at 20:49, musa fedakar <musaf...@gmail.com> wrote:
>
> ObjectValue(attribute_name='aciklama', left=3*cm,width=10*cm,get_value=lambda instance: 'desc: ' + (instance.aciklama) ,style={'fontName': 'helvetica', 'fontSize': 8})
Try to use the unicode encoding, be sure to have your file in unicode
format too and prefer unicode string to avoid some problems, instead
of:
'descr:' + instance.acicklama
Use:
u'descr: %s' % (instance.acicklama,)
This way you assure to have unicode stuff so geraldo and reportlab
tool can print out the PDF in the right way.
def prepare_additional_fonts(self):
"""This method loads additional fonts and register them using ReportLab
PDF metrics package.
Just supports TTF fonts, for a while."""
pdfmetrics.registerFont(TTFont('sanz','/usr/share/fonts/truetype/freefont/FreeSans.ttf'))
pdfmetrics.registerFont(TTFont('sanzbold','/usr/share/fonts/truetype/freefont/FreeSansBold.ttf'))
if not self.report.additional_fonts:
.
.
.
style={'fontName': 'sanzbold', 'fontSize': 8}