关于利用trml2pdf生成PDF出现【flowable not yet implemented】错误的原因

时间:2023-02-01 10:07:04

最近一直在研究利用RML制作PDF,中间一直遇到各种flowable not yet implemented的错误,郁闷球坏了,今天在去trml2pdf.py源码中查看,发现trml2pdf.py对很对RML标签并没有解析:

def _flowable(self, node):
if node.localName=='para':
style = self.styles.para_style_get(node)
return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
elif node.localName=='name':
self.styles.names[ node.getAttribute('id')] = node.getAttribute('value')
return None
elif node.localName=='xpre':
style = self.styles.para_style_get(node)
return platypus.XPreformatted(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str','dedent':'int','frags':'int'})))
elif node.localName=='pre':
style = self.styles.para_style_get(node)
return platypus.Preformatted(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str','dedent':'int'})))
elif node.localName=='illustration':
return self._illustration(node)
elif node.localName=='blockTable':
return self._table(node)
elif node.localName=='title':
styles = reportlab.lib.styles.getSampleStyleSheet()
style = styles['Title']
return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
elif node.localName=='h1':
styles = reportlab.lib.styles.getSampleStyleSheet()
style = styles['Heading1']
return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
elif node.localName=='h2':
styles = reportlab.lib.styles.getSampleStyleSheet()
style = styles['Heading2']
return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
elif node.localName=='h3':
styles = reportlab.lib.styles.getSampleStyleSheet()
style = styles['Heading3']
return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
elif node.localName=='image':
return platypus.Image(node.getAttribute('file'), mask=(250,255,250,255,250,255), **(utils.attr_get(node, ['width','height'])))
elif node.localName=='spacer':
if node.hasAttribute('width'):
width = utils.unit_get(node.getAttribute('width'))
else:
width = utils.unit_get('1cm')
length = utils.unit_get(node.getAttribute('length'))
return platypus.Spacer(width=width, height=length)
elif node.localName=='pageBreak':
return platypus.PageBreak()
elif node.localName=='condPageBreak':
return platypus.CondPageBreak(**(utils.attr_get(node, ['height'])))
elif node.localName=='setNextTemplate':
return platypus.NextPageTemplate(str(node.getAttribute('name')))
elif node.localName=='nextFrame':
return platypus.CondPageBreak(1000) # TODO: change the 1000 !
else:
sys.stderr.write('Warning: flowable not yet implemented: %s !\n' % (node.localName,))
return None
在这段代码中查找<nextPage/>、<outlineAdd>、<storePlace>......这些标签都没有,

现在解决的方法就是,换用reportlab api直接写或者修改trml2pdf.py的源码来解析无法识别的一些标签


好吧,我现在也不纠结了,如果哪位大神有比较全面的rml转pdf的工具,希望传给小弟一份 邮箱:513614549@qq.com