我正在尝试将MathplotLib生成的图像渲染为ReportLab创建的pdf。请修复。你知道吗
graph1 = Image(filename='Graphs/AvgAnnMedCostPerEE.png',x=50,y=50,width=None,height=None,path='Graphs/AvgAnnMedCostPerEE.png')#,kind='direct',mask='auto',hAlign='CENTER',)
first_graph_table_header = [["Average Annual Medical Cost Per Employee",""],
["",graph1]]
first_graph_page_style = TableStyle([('SPAN', (0, 0), (1, 0))])
# ('ALIGN', (0, 3), (8, 3), 'CENTER'),
# ('ALIGN', (0, 0), (8, 0), 'CENTER'),
# ('VALIGN', (0, 0), (8, 0), 'MIDDLE'),
# ('VALIGN', (2, 3), (6, 3), 'MIDDLE'),
# ('BACKGROUND', (0, 2), (8, 2), colors.HexColor('#305496')),
# ('BACKGROUND', (0, 3), (8, 3), colors.HexColor('#b4c6e7')),
# ('BACKGROUND', (8, 2), (8, 3), colors.orange),
# ('FONT', (0, 2), (-9, -2), 'Helvetica-Bold', 10),
# ('FONT', (2, 3), (-7, -1), 'Helvetica-Bold', 12),
# ('FONT', (3, 3), (-3, -1), 'Helvetica-Bold', 10),
# ('TEXTCOLOR', (0, 2), (-9, -2), colors.white)
# ])
g1 = Table(first_graph_table_header, colWidths=[14.75, 161],
rowHeights=[5.5*mm, 2*inch])
g1.setStyle(first_graph_page_style)
self.story.append(g1)
self.story.append(Image(filename='Graphs/AvgAnnMedCostPerEE.png',x=50,y=50,width=None,height=None,path='Graphs/AvgAnnMedCostPerEE.png'))
self.story.append(PageBreak())
# def createGraphs(self, canvas, doc):
# ----------------------------------------------------------------------
if __name__ == "__main__":
t = CoverPage_Index()
t.run()
我一直在获取AttributeError:映像实例没有属性“getKeepWithNext”
我也有同样的问题。经过一点疯狂,我明白了原因是名字冲突。这就是对我有效的解决方案。 您需要一个可流动的映像,但是名称Image在导入的类中可能不是唯一的。 首先,给要使用的Image类指定一个在导入时确定是唯一的名称;我使用了GNAA(到底谁会编写一个名为GNAA的类?)。你知道吗
然后你可以用它来挑选一个图像。在本例中,映像与python程序位于同一目录中。重要提示:使用jpg,因为png可能不起作用:
现在的形象是正确的一个,流动和所有正确的参数需要。 我没有调查图像的二倍频器在哪里,但是这个技巧很有效。你知道吗
相关问题 更多 >
编程相关推荐