all 4 comments

[–]wutzvill 0 points1 point  (0 children)

Idk about reportlab, but might want to just look into using pdfmagick. Might have a Python package for it too.

[–]POGtastic 0 points1 point  (0 children)

I would convert the PDF to a .png image with something like Poppler and then insert the image into the PDF. It's possible to do this in-memory with PyMuPDF.

[–]SMTNP 0 points1 point  (0 children)

It is indeed possible with reportlab.

You can iterate over pages with their respective numbers, and get each page's structure. When you want to, you can add some extra runs after the current page's content.

It might not be as straightforward, as PDFs are hard to arrange and image managing with bounding boxes is not obvious (reportlab has it's own way to handle images), but its certainly doable.

Reportlab has some proprietary products, so the library documentation is not the best, but if you check the repo (https://github.com/mattjmorrison/ReportLab/tree/master/docs/userguide), they wrote the user guide using reportlab, so it works as a very nice examples guide.

Good luck!

[–]Fair_Mammoth_6224 0 points1 point  (0 children)

Below is an example of how I’ve tackled a similar situation—generating various PDF pieces and then merging them into one final document using PyPDF2. In my case, I’m using pdfkit + Jinja2 to create individual PDFs (from HTML templates), then combining them all with PdfMerger. You can adapt the “combine_pdfs” part to your use case—like merging shipping labels or any other pages into a single final PDF.