eHow launches Android app: Get the best of eHow on the go.

How To

How to Create PDFs with PHP

Contributor
By Jeffrey Ober
eHow Contributing Writer
(0 Ratings)

PDF stands for "portable document format." PHP stands for "personal home page." With a little bit of help and some solid basic knowledge of PHP script language, you can actually combine these two standards to create Web pages written using the PHP processor that actually create PDF files on demand. This will allow your website and your users to create files that are customized and perhaps even filled in with data from a database, if your PHP is able to connect to a database and retrieve information from it.

Difficulty: Moderately Challenging
Instructions
  1. Step 1

    Set up your website with the PHP processor so that all your PHP web pages will be processed through the PHP processor.

  2. Step 2

    Create a new web page with a PHP ending. You can use any html or text editor to do this.

  3. Step 3

    Obtain a class definition that defines the PDF layout and format, such as fpdf. This is a plain-text file that contains the PHP code to define a class. You could write this yourself, but the fpdf (free pdf) class file contains more than 1,700 lines of code, so getting one that's already been made for you is easier. Get this file and place it in the same directory as the PHP file you created in Step 2.

  4. Step 4

    Include the fpdf class files in your PHP web page with the "require" command:
    require('fpdf.php');

  5. Step 5

    Set up your pdf object using the methods of the pdf class you have created. This will build the pdf file for you and display it in the browser. The exact methods may vary by class file, but will usually consist of creating a pdf object (new FPDF();) and displaying the object ($pdf->output;).

References

Resources
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Demand Media
eHow_eHow Technology and Electronics