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

Rollins, Robert B. rrollins at caltech.edu
Wed Aug 17 21:22:01 EDT 2022


I’ve found that attempting to include a TableOfContents with the ~700 page PDF I’ve generating causes a 3/4-page chunk of blank space to get added to the beginning of the cover page, pushing most of the content in it down into a second page. This increases the length of my document by 1 page, and plays absolute havoc with the TableOfContents itself.

In fact, this completely breaks PDF generation, because it forces all the TOCEntries to change page number on every other pass of multiBuild(), since the blank space doesn’t get added on odd-numbered passes (and HOO boy was it an adventure to figure THAT detail out!). Since TableOfContents.isSatisfied() never returns True, due to even-numbered passes having different page numbers from odd-numbered passes, multiBuild() just loops infinitely until it hits maxPasses, and then kills itself.

I only discovered that the blank space was being added at all because some combinations of styles and text content make the TOC itself change length enough between passes to make the page numbers coincidentally remain the same on each pass, and the PDF generation successfully finishes. But then I’ve still got a huge blank spot at the front of the PDF.

Does anyone know what could possibly because causing this large chunk of blank space to get added to my first page? It doesn’t appear to be due to some spurious extra Flowable being added to the beginning of my story on even-numbered passes, so I’m completely baffled as to what might be happening.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20220818/0409bd2c/attachment.htm>


More information about the reportlab-users mailing list