我正在使用Python reportlab生成pdf
您知道如何在文档的第一页设置背景图像吗
这是我的密码。插入图像,但不作为背景图像。 我非常感谢你的帮助
class MyDocTemplate(BaseDocTemplate):
def __init__(self, filename, **kw):
self.allowSplitting = 0
apply(BaseDocTemplate.__init__, (self, filename), kw)
template = PageTemplate('normal', [Frame(2.5*cm, 2.5*cm, 15*cm, 25*cm, id='F1')])
self.addPageTemplates(template)
def afterFlowable(self, flowable):
"Registers TOC entries."
if flowable.__class__.__name__ == 'Paragraph':
text = flowable.getPlainText()
style = flowable.style.name
if style == 'Heading1':
self.notify('TOCEntry', (0, text, self.page))
if style == 'Heading2':
self.notify('TOCEntry', (1, text, self.page))
image = Image('CPReportBackGroundImage.png')
#story.append(KeepInFrame("100", "200", image))
story.append(KeepInFrame(14*inch, 22*inch, [image]))
### First page
#story.append(Spacer(1, 10))
text="<b>My title</b>"
story.append(Paragraph(text, coverPage_Large_Style))
#story.append(Spacer(1, 12))
doc = MyDocTemplate(pdfReportName)
doc.multiBuild(story)
问候,, 叶甫盖尼
目前没有回答
相关问题 更多 >
编程相关推荐