That’s understandable. Maybe try commenting out all the generating code and adding it back piece by piece until the document size balloons, then you’ve found your culprit.
The MuPDF ‘mutool’ is pretty handy for dumping internal PDF content to see which parts are large.
The MuPDF ‘mutool’ is pretty handy for dumping internal PDF content to see which parts are large.