Generate Multi-Line Text Blocks in PHP

PHP comes with some nice functions for generating text using True Type Fonts. Unfortunately their API doesn't provide an easy way to generate text with multiple lines at arbitrary angles. A few years back I posted a script online that allows programmers to overcome this challenge in PHP using the GD library.

My primary goal was to generate thumbnail images for business cards and postcards. But of course, there are many applications, such as creating online greeting cards, or electronic invitations, etc. Click here to download the PHP source in a text document. The comments inside the source code should be self explanatory enough.

This URL got lost for a while in some server rearrangements and I noticed that people were still linking to it from my web logs. If there is anyone out there that still needs this code, I hope it helps!

The GD Library

First you have to make sure that your PHP installation is compiled with GD support. I remember there being some kerning issues with certain fonts when text is rotated at certain angles. I am not sure if those bugs have been fixed by now.

I stopped using the GD library for generating thumbnail images on this server a while ago. It is not compiled into this version of PHP so I can't show a working example like I did before. Nonetheless, the algorithms which I posted give come clues how to create multi-line blocks of text on other platforms if you are willing to port it.





Happy Coding!
~ Brian ~ Webmaster ~ Prints Made Easy, Inc.





Terms   |   Privacy   |   About Us   |   Pricing   |   Site Map   |   Customer Service

Business Cards   |   Postcards   |   Envelopes   |   Letterhead  |  Banners  |  Business Card Magnets  |  Posters

© Prints Made Easy Inc. 2002 - 2014