reingart/pyfpdf

Generating pdf files in http context produces unexpected results

wayne530 opened this issue · 1 comments

I'm trying to generate a pdf synchronously in an http request so I can return the generated pdf as a file download in its response. Using 1.7.2 and the newest fpdf2 (which btw, disabled issues for some reason; cc: @alexanderankin), the first pdf generated after the server starts up works perfectly fine and matches the size of the same pdf generated via command line, however, with subsequent requests, the file seemingly gets progressively smaller (no code changes or server restarts) with odd issues like pages overlapping each other, random blank pages, etc.

This unfortunately makes the library unusable when generating pdf files synchronously in a web request.

Wondering if anyone has run into this issue and has found a workaround, or if anyone happens to how it would be possible that consecutive reloads of the page that generates the pdf would produce different results, with no code/server/data changes?

Of course, shortly after posting this, I was able to find the issue and resolve it :)