drw = _rml_draw(self.localcontext ,self.node,self.styles, images=self.self2.images, path=self.self2.path, title=self.self2.title)
drw.render(self.canv, None)
+# Workaround for issue #15: https://bitbucket.org/rptlab/reportlab/issue/15/infinite-pages-produced-when-splitting
+original_pto_split = platypus.flowables.PTOContainer.split
+def split(self, availWidth, availHeight):
+ res = original_pto_split(self, availWidth, availHeight)
+ if len(res) > 2 and len(self._content) > 0:
+ header = self._content[0]._ptoinfo.header
+ trailer = self._content[0]._ptoinfo.trailer
+ if isinstance(res[-2], platypus.flowables.UseUpSpace) and len(header + trailer) == len(res[:-2]):
+ return []
+ return res
+platypus.flowables.PTOContainer.split = split
+
class _rml_flowable(object):
def __init__(self, doc, localcontext, images=None, path='.', title=None, canvas=None):
if images is None:
# Reset Page Number with new story tag
fis.append(PageReset())
story_cnt += 1
- if self.localcontext and self.localcontext.get('internal_header',False):
- self.doc_tmpl.afterFlowable(fis)
- self.doc_tmpl.build(fis,canvasmaker=NumberedCanvas)
- else:
- self.doc_tmpl.build(fis)
+ try:
+ if self.localcontext and self.localcontext.get('internal_header',False):
+ self.doc_tmpl.afterFlowable(fis)
+ self.doc_tmpl.build(fis,canvasmaker=NumberedCanvas)
+ else:
+ self.doc_tmpl.build(fis)
+ except platypus.doctemplate.LayoutError, e:
+ e.name = 'Print Error'
+ e.value = 'The document you are trying to print contains a table row that does not fit on one page. Please try to split it in smaller rows or contact your administrator.'
+ raise
def parseNode(rml, localcontext=None, fout=None, images=None, path='.', title=None):
node = etree.XML(rml)