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
评论列表
文章目录