We love things that Inspire.
This is a space where you will find our latest Inspire moments, client comments and some general thoughts and findings from the team at Inspire.

Dynamic PDFs – TCPDF setPageRegions() Function

For one of our recent websites (www.moneyandmorals.org) we have been dynamically creating PDFs. Using the excellent TCPDF PHP Library. The only problem we ran into was wrapping text around an image.

Fortunately a recent update to the library has added the setPageRegions() function. With this function you can define an area that text should wrap around. Then using the Image() function we can place an image in that area. You do need to make sure you have reset the setPageRegions() by calling it without any variable after otherwise it causes some interesting effects to tables further on in the document.

You can see below the output of the dynamic PDF.

Leave a Response