Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ReportLab LayoutError:第页太大_Python_Pdf Generation_Reportlab_Platypus - Fatal编程技术网

Python ReportLab LayoutError:第页太大

Python ReportLab LayoutError:第页太大,python,pdf-generation,reportlab,platypus,Python,Pdf Generation,Reportlab,Platypus,我正在使用ReportLab执行我的第一个程序,我事先不知道分页符将落在哪里,我遇到了问题。为了保持简单,我使用了SimpleDocTemplate。我的流动性看起来像这样: flowables = [Paragraph("Some title", style=headerParagraphStyle), Spacer(0, 10), Paragraph("first paragraph", style=bodyParagraphStyle),

我正在使用ReportLab执行我的第一个程序,我事先不知道分页符将落在哪里,我遇到了问题。为了保持简单,我使用了
SimpleDocTemplate
。我的流动性看起来像这样:

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(),
             ...]
当我构建PDF时,只要我的
n
m
或一页中有多少正文段落,一切都会正常进行,但如果它们被覆盖,我会得到如下错误:

reportlab.platypus.doctemplate.LayoutError: Flowable <Paragraph at 0xb79800 frame=normal>20th paragraph: too large on page 3
spireport2.csv:

College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æone with a line break; let's see what happensæææweird charactèrs áÈ-{ô College of Health & Public AffæCriminal Justice/Legal Studiesæsample@mail.comæAn InstructoræFOUNDATIONS OF LAW ENFORCEMENTæCJE5021æ0001æ1370æ 7ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræHARLEM, HAITI, AND HAVANAæAML3615æ0001æ1370æ 35ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræCONT AMERICAN WOMEN S FICTIONæAML3283æ0001æ1370æ 35ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræPOST-WORLD WAR II FICTIONæLIT4303æ0M01æ1370æ 32ææææô College of Arts & HumanitiesæEnglishæbill@gates.comæAn InstructoræMAJOR AMERICAN AUTHORSæAML4300æ0001æ1370æ 33ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræPRACTICAL CRITICISMæENG3010æ0001æ1370æ 36ææææô 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ示例注释æ我喜欢它æ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205æ一个带断线的;让我们看看发生了什么奇怪的事情 卫生与公共事务学院(刑事司法/法律研究)sample@mail.comæ讲师æ执法基础æCJE5021æ0001æ1370æ7ææ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205ææ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205ææ 健康与公共事务学院健康信息管理example@example.comæ讲师æ医学术语æHSC3537æ0M01æ1370æ205ææ 艺术与人文学院英语spam@me.com教官哈莱姆、海地和哈瓦那 艺术与人文学院英语spam@me.comæ讲师æCONT美国女性小说æAML3283æ0001æ1370æ35ææ 艺术与人文学院英语spam@me.com教官二战后小说 艺术与人文学院英语bill@gates.comæ讲师æ美国主要作家æAML4300æ0001æ1370æ33ææ 艺术与人文学院英语spam@me.comæ讲师æ实践批评æ英语3010æ0001æ1370æ36æ
我自己找到了一个解决方法。基于一些,我能够让我的代码可靠地工作。解决方案虽然很难看,但还是将我所有的
段落
包装在代码的一部分中,该部分为
内的学生评论创建
段落
。例如,我将一行相关内容改为:

reportDocContent.append(KeepTogether(Paragraph(commentParagraph, style=commentParagraphStyle)))

现在它可以工作了(至少,在尝试了大量样本数据后,我还没能打破它)。

看起来这是一个老问题,但我最近遇到了同样的错误,我来这里寻求一些建议。我做的修复是将垫片尺寸改为旧尺寸的一半。它以前是垫片(1,0.2*inch)我把它改成了间隔垫圈(1 College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æsample commentsææi like itæô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205æone with a line break; let's see what happensæææweird charactèrs áÈ-{ô College of Health & Public AffæCriminal Justice/Legal Studiesæsample@mail.comæAn InstructoræFOUNDATIONS OF LAW ENFORCEMENTæCJE5021æ0001æ1370æ 7ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Health & Public AffæHealth Info Mgmtæexample@example.comæAn InstructoræMEDICAL TERMINOLOGYæHSC3537æ0M01æ1370æ 205ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræHARLEM, HAITI, AND HAVANAæAML3615æ0001æ1370æ 35ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræCONT AMERICAN WOMEN S FICTIONæAML3283æ0001æ1370æ 35ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræPOST-WORLD WAR II FICTIONæLIT4303æ0M01æ1370æ 32ææææô College of Arts & HumanitiesæEnglishæbill@gates.comæAn InstructoræMAJOR AMERICAN AUTHORSæAML4300æ0001æ1370æ 33ææææô College of Arts & HumanitiesæEnglishæspam@me.comæAn InstructoræPRACTICAL CRITICISMæENG3010æ0001æ1370æ 36ææææô
reportDocContent.append(KeepTogether(Paragraph(commentParagraph, style=commentParagraphStyle)))
  File "/opt/python2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/doctemplate.py", line 1117, in build
    BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
  File "/opt/python2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/doctemplate.py", line 880, in build
    self.handle_flowable(flowables)
  File "/opt/python2.7/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-x86_64.egg/reportlab/platypus/doctemplate.py", line 793, in handle_flowable
    raise LayoutError(ident)
reportlab.platypus.doctemplate.LayoutError: Flowable <Spacer at 0xf01440 frame=normal>...(1 x 14.4) too large on page 10 in frame 'normal'(439.275590551 x 628.28976378) of template 'Later'