reportlab
の段落を取得しようとしていますが、動作させることができません。例外値:引数テキストの型が無効です
このコードは正常に動作します:
p.setFont('Helvetica',8)
labo = str('CANCIÓN').decode('utf-8')
p.setFillColor(HexColor('#ff8100'))
p.drawString(350,736, labo)
しかし、このコードはしていません:
styles = getSampleStyleSheet()
labo = Paragraph("Generating Reports with Python", styles["Heading1"])
p.drawCentredString(400,600, labo)
それは返します:私は間違って何をやっている
Exception Value: invalid type for argument text
?
私はすべての必要なモジュールをインポートしたと思います。
#!/usr/bin/python
# -*- encoding: utf-8 -*-
from reportlab.pdfgen import canvas
from django.http import HttpResponse
from reportlab.lib.pagesizes import letter
from reportlab.lib.colors import HexColor
from reportlab.lib.utils import ImageReader
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph
import os
from io import BytesIO
import PIL.Image
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont