相关疑难解决方法(0)

ReportLab LayoutError:页面太大

我正在使用ReportLab进行我的第一个程序,我事先不知道页面中断会丢失的地方,我遇到了麻烦.为了简单起见,我正在使用SimpleDocTemplate.我的flowables看起来像这样:

flowables = [Paragraph("Some title", style=headerParagraphStyle),
             Spacer(0, 10),
             Paragraph("first paragraph", style=bodyParagraphStyle),
             Paragraph("second paragraph", style=bodyParagraphStyle),
             ...
             Paragraph("nth paragraph", style=bodyParagraphStyle),
             PageBreak(),
             Paragraph("Some title", style=headerParagraphStyle),
             Spacer(0, 10),
             Paragraph("first paragraph", style=bodyParagraphStyle),
             Paragraph("second paragraph", style=bodyParagraphStyle),
             ...
             Paragraph("mth paragraph", style=bodyParagraphStyle),
             PageBreak(),
             ...]
Run Code Online (Sandbox Code Playgroud)

当我构建我的PDF时,只要我n或者m多个正文段落在一个页面上,一切都很顺利,但如果它们运行完毕,我会得到如下错误:

reportlab.platypus.doctemplate.LayoutError: Flowable <Paragraph at 0xb79800 frame=normal>20th paragraph: too large on page 3
Run Code Online (Sandbox Code Playgroud)

似乎无法找到为什么这种情况一直发生在我身上的充分理由.有什么建议?即使我删除PageBreaks(),它也会这样做.所有段落都相对较短,大多不到一个句子/行.

ETA:我发布了为我生成错误的所有代码(删除了少量标识符).我已将其转换为读取CSV文件,因此我也发布了其内容.运行它时,此代码为我生成的确切错误是:

Traceback (most recent call last):
  File "./spice_dev.py", line 355, in 
    departmentReportDoc.build(eachDepartment.report, onFirstPage=onReportPage, onLaterPages=onReportPage)
  File "/usr/local/lib/python2.6/site-packages/reportlab/platypus/doctemplate.py", line 1010, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File …

python pdf-generation reportlab platypus

10
推荐指数
1
解决办法
6520
查看次数

标签 统计

pdf-generation ×1

platypus ×1

python ×1

reportlab ×1