Skip to content Skip to sidebar Skip to footer

Reportlabs Django Integration

I'm following this link to integrate the ReportLabs in Django. I did everything correctly but I get an error saying - Exception Type: RenderPMError Exception Value: Can't set

Solution 1:

To register a font:

import os
from reportlab.pdfbase import pdfmetrics  
from reportlab.pdfbase.ttfonts import TTFont

pdfmetrics.registerFont(TTFont("Arial", os.path.join(settings.PROJECT_ROOT, 'static', 'fonts', 'arial.ttf'))) # here i have my fonts for PDF's

to use it, ex:

page = canvas.Canvas(response, pagesize=A4, pageCompression = 0)

canvas.setFont('Arial',9)

Solution 2:

You have to download the fonts and place them in your ReportLabs package.

You need these files:

http://www.reportlab.com/ftp/fonts/pfbfer.zip

Unzip them in:

/path/to/your/python/site-packages/reportlab/fonts

Post a Comment for "Reportlabs Django Integration"