spacer
Web Development Tutorials PHP Tutorials
 Developer Newsletter

Tutorials
AJAX
ASP
CGI & Perl
CSS
Flash
HTML
Illustrator
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML
Miscellaneous


Scripts Directory
AJAX Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Web Hosting Directory
ASP.NET
Budget
Dedicated Servers
Ecommerce
Linux
Resellers
Shared
Small Business
Windows

Developer Manuals
Learn HTML
Learn PHP
Learn CSS
Learn AJAX
Learn JavaScript
Learn Pear
Free White Papers

Developer Resources
Developer Tools
Developer Content
Survey Software
Dedicated Servers




Easy PDF Generation in PHP

By Akash Mehta
2008-03-01


Further reading on FPDF

In this tutorial, we've put together a basic PDF file with nothing but a line of text in it. However, FPDF is capable of far more. The library has a lot of complex yet high level functionality available - you can work with headers and footers, easily handle page breaks, insert images, use multiple columns and tables, and even insert hyperlinked text.

The fpdf.org website has an excellent collection of tutorials; head over to the FPDF tutorial page and have a browse through. You'll notice that the tutorials use OOP to construct pages, defining a class that extends the core FPDF class. The library is very flexible, and works just as you'd expect any normal PHP class to - and this is where its strength lies. Experiment with the library as you read through the tutorials, and you will quickly find how easy it is to create detailed PDF files in PHP.



Tutorial Pages:
» Introduction
» Why would you want to generate PDFs?
» Options for PDF Generation
» Hello World with FPDF
» Examining the code
» Further reading on FPDF


Related Tutorials:
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK
» Installing PHP on Windows

Recent Comments
Draicone
March 6, 2008, 7:30 am

Glad you enjoyed the tutorial.

There's definitely a lot of potential for achieving complex PDF documents programmatically, although beyond a point there's only so much the FPDF library can do. Luckily, you can extend it natively :)

The example in the tutorial is really rather basic, to be honest, but I tried to explain the fundamentals really clearly so that people can go and create fantastic PDFs. What they do from here is up to them :)

We're really seeing more sites offer a "download as PDF" option, often very subtly - such as next to the email a friend link on articles. Just a small PDF icon that seems to be gaining in popularity very quickly.

What I really want to see, however, is embedded HTML documents in PDFs, similar to OpenOffice's approach to editable PDFs.

ryanhellyer
March 1, 2008, 3:19 pm

Thanks for the tutorial.

I tried a WordPress plugin a while back for doing this, but it tended to generate rather ugly looking PDFs. This is definitely going to become more common in the future though. This is a particularly useful technique if you want to give your users the ability to download entire web pages for future reading. PDF's are much more user friendly for downloading and subsequent printing than a web page, so if you can generate one from the raw HTML then that would be a very handy feature.

Read all comments



About the NetVisits, Inc Network | Write For Us | Advertise
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: