Created
January 4, 2013 13:26
-
-
Save bgnori/4452571 to your computer and use it in GitHub Desktop.
reportlabのplatypusを使ってtableを描画するサンプル。wrapOnを呼びなさいということ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from reportlab.pdfgen import canvas | |
from reportlab.lib.pagesizes import A4 | |
from reportlab.lib.units import mm | |
from reportlab.pdfbase import pdfmetrics | |
from reportlab.pdfbase.ttfonts import TTFont | |
from reportlab.lib import colors | |
from reportlab.platypus import Table | |
pdfmetrics.registerFont(TTFont('IPA Gothic', | |
'/usr/share/fonts/ipa-gothic/ipag.ttf')) | |
xmargin = 8.4*mm | |
ymargin = 8.8*mm | |
swidth = 48.3*mm | |
sheight = 25.4*mm | |
c = canvas.Canvas("/home/nori/Desktop/work/pdf/forDayCare/test.pdf", pagesize=A4) | |
#c.drawString(xmargin, ymargin, u"どや、pdfやで。reportlab!") | |
t = Table([['a', 'b'], ['1', '2']]) | |
t.setStyle([('TEXTCOLOR', (0,0), (1,0), colors.red)]) | |
t.wrapOn(c, 100*mm, 100*mm) | |
t.drawOn(c, 100*mm, 100*mm) | |
c.showPage() | |
c.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment