PDF output classes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
batfastad
Forum Contributor
Posts: 433
Joined: Tue Mar 30, 2004 4:24 am
Location: London, UK

PDF output classes

Post by batfastad »

Hi everyone

I'm looking for some suggestions for PDF output classes... with some pretty specific requirements.
Previously we used a PHP class called FPDF, then moved over to TCPDF (a highly modified version of FPDF).

FPDF works well for us because it allows accurate placement of data/items on PDF pages.
Features added in TCPDF are that it can support limited HTML code, <b> <i> <u> <font size="" color=""> <img> which is great for allowing users to customise invoices with their own formatting using a simple WYSIWYG editor.

The problem is though we've been unable to find a way to centre align HTML code that gets printed out. It's easy for regular text, but have not managed to centre align HTML code within a PDF Cell.
Also support for entity codes and strange characters in UTF-8 means embedding the whole font inside the PDF which leads to massive file sizes for 1 page text documents.

I have 2 questions:

1) Users enter basic HTML mark up to style up sections of text within invoices and reports. Small 5-10 line description fields, and the letterhead footer etc.
I thought of using some sort of BB code at first, but found that TCPDF supported HTML and went with that.
Is this the best way to have basic text formatting stored in a database to output to PDF?

2) Does anyone know of any commercial solutions that can do what I'm looking for?
Basic HTML formatting support, and support for many different special characters?
Ideally I'd like to be able to fully integrate it within our solution.

I've had a dig around and found things like DomPDF and HTML2PDF, but they're more designed to convert a whole HTML page.
The problem with that is it means we can't control the layout as accurately as we could with FPDF - placing items on the PDF down to milimetre accuracy.

Anyone have any ideas / suggestions on how to proceed with this?

Thanks
Ben
Post Reply