Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mallaury's avatar

Library to add text and shape to an existing PDF

Hello,

I am looking for a library to add annotations: shapes, images and text to an existing PDF file (from a given page and coordinate).

dompdf seems to be widely used, but I can not find how to use it with an existing PDF.

Do you have any ideas?

Thanks

0 likes
2 replies
Flu's avatar

Hmm not sure if that is the best (and for your special case a working) solution but you could convert this pdf to an image (for example with imagick), render it to a route/view, add some div layers / content over the image and then re-take a snapshot pdf for example with the Spatie Browsershot library (https://github.com/spatie/browsershot) from the url.

mallaury's avatar

@Flu Thank you for your reply. I think I misspoke. I am looking for a backend library. For the frontend, I already have the solution, I load the PDF with PdfJS and I actually add canvas layers.

Please or to participate in this conversation.