PHP/PDF with Background Image

Hello SitePoint,

Hoping you guys can help me out… I’m very familiar with PHP, but not done much with the built in PDF functions or the classes out there for PDF generation. Here’s what I’m trying to do:

I need to generate a Letter size PDF file with a background image, and some dynamic text over top of it that is centered and wraps if any lines are too long.

On the surface, I thought this would be really easy, but I’m having issues with getting the text to wrap and be centered, as well as having it on top of the image.

I’ve written and torn down code about 3 times now, first with the built in PDF functions, and then with two classes I found on the web. And I’m really frustrated.

Does anyone have some info on how to do this?

It would be greatly appreciated!

You might have more luck having your program output LaTeX or another TeX variant, which is commonly used for producing print documents. You’ll find many more resources on laying out your document this way, and there are many utilities for converting the LaTeX markup to a PDF file.

Have you tried fpdf? You can designate a cell and your text should wrap inside it.