我试图打印矩形,但我不知道怎么做,这段代码工作正常,但我不知道如何附加矩形。
我真的很感激任何帮助。
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.pagesizes import letter
from reportlab.platypus import Paragraph, SimpleDocTemplate, Flowable, Spacer
styles = getSampleStyleSheet()
draw = Drawing(500, 200)
draw.add(Rect(0, 100, 500, 100))
hola = ParagraphStyle('')
hola.fontSize = 9
hola.leading=0
story = []
#add some flowables
story.append(Paragraph("This is a ",hola))
story.append(Spacer(0,20))
story.append(Paragraph(" <i>Normal</i> style.",hola))
doc = SimpleDocTemplate('mydoc.pdf',pagesize = letter)
doc.build(story)
谢谢!
答案 0 :(得分:1)
你需要在你的故事中加上你的平局:
story.append(draw)