[reportlab-users] Blank space being added to beginning of PDF when using TableOfContents

Robin Becker robin at reportlab.com
Fri Aug 19 06:43:37 EDT 2022


Hi Robert,

you may get more information by trying to reduce the problem size; even 25 pages is too much and your code is not 
runnable by anyone else. Trying to simulate what's happening by inspection is probably not going to be possible.

Since it seems that you are getting extra space at the start of the story. It might be an idea to try and see what is 
actually present at the story start; and if you can see that it's obviously wrong then you should be able to determine 
where it gets added. Again it would be a good idea to reduce the number of TOC entries to see if the extra space is 
proportional to some count of entries.

The story is just a list of flowables so can be a list subclass which can be used to inspect/instrument inserts/appends 
etc etc.

None of the tests in reportlab/tests seem to have a cover page so perhaps there's a bug; it would be interesting to know 
if you looked at one of those as a model. I do know that one of the problems with dynamic TOCs is that they do occupy 
space and obviously those pages have to be accounted for. The reportlab tests seem to try several different strategies 
for the dynamic case.

On 18/08/2022 19:50, Rollins, Robert B. wrote:
> I tried cutting all the actual content of out the PDF, to reduce it to just the headings that I use to build the ToC from. This cut it down to ~25 pages, and I tried building it with the default TableOfContents class again (I found a hacky workaround for this issue last night by subclassing TableOfContents, but it’s REALLY hacky). Unfortunately, with the default TableOfContents, I went right back to getting the infinite loop problem in multiBuild(), which ends with this:
> 
>>    File "/catalog/catalog/core/jobs/pdf_generator.py", line 794, in render_full_catalog
>      self.doc.multiBuild(self.flowables)
>    File "/catalog-ve/lib64/python3.8/site-packages/reportlab/platypus/doctemplate.py", line 1182, in multiBuild
>      raise IndexError("Index entries not resolved after %d passes" % maxPasses)
> IndexError: Index entries not resolved after 10 passes
> 
> Using a debugger to manually kill the looping and force it to finish the build gave me the attached PDF. The huge blank spot at the beginning is there, and is the exact same size as the full 700-page PDF. The page numbers in the ToC are off by one as well (something I fixed manually in my hack).
> 
> The code even just to build this tiny version of the PDF is… a lot. I’ll include the sections that I think are probably relevant.
> 
> 
........
-- 
Robin Becker


More information about the reportlab-users mailing list