Create a PDF Document in PHP and View in the Browser

A sample PHP script using PDFBuilderASP

This example demonstrates the use of the PDFBuilderASP component in a PHP script to generate a single page PDF document and display it in the client browser. The document is a simple invoice which is customised to show the name and address of a customer which have been sent to the PHP script using an HTTP POST operation. This represents a typical application for this component.

To run this example now, complete the name and address fields further down this page and then click on the "Create PDF" button to submit the form data to the sample script on our server. (Note that we are not recording the data you enter, it is just being used to build the example PDF). After the script runs, a fictitious invoice in PDF format will be displayed in your browser.

To set this example up on your own server, download the trial version of PDFBuilderASP and a copy of the PHP script used for this demo from the links below. Note that this component is a COM object and can only be used on servers running a Windows operating system.

Trial version of PDFBuilderASP. (504kB)

Download the example PHP script. (4kB)

Run the Example Script to Create an Invoice

By clicking on the "Create PDF" button below, the information entered in the name and address fields is submitted to a PHP script on our server. This script then creates a PDF document using PDFBuilderASP. The script demonstrates how images are added (a company logo), how graphics are drawn (various rectangles and lines to show boxes on the invoice) and the writing of several text fields. Most of the text on the document is fixed, but the three data fields for the customer's name and address will be completed using the submitted information.

Finally, the document is displayed in the browser after being saved temporarily on the server by PDFBuilderASP.



Please enter a name (an imaginary one if you prefer).


Also, enter the first line of an address.


..and the second line of an address.


Finally, click the button below to generate the invoice.