13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solution Components<br />

777<br />

free but does not always produce good output for documents with images or nonst<strong>and</strong>ard<br />

fonts.The ps2pdf converter comes with the Ghostscript package mentioned previously.<br />

Obviously, if you are going to create a PDF file this way, you will need to create a<br />

PostScript file first. Unix users typically use either the a2ps or dvips utilities for this<br />

purpose.<br />

If you are working in a Windows environment, you can also create PostScript files<br />

without Adobe Distiller, albeit via a slightly more complicated process.You need to install<br />

a PostScript printer driver. For example, you can use the Apple LaserWriter IINT driver.<br />

If you don’t have a PostScript driver installed, you can download one from Adobe at<br />

http://www.adobe.com/support/downloads/product.jsp?product=44&platform=<br />

Windows.<br />

To create your PostScript file, you need to select this printer <strong>and</strong> the Print to File<br />

option, typically found on the Print dialog box.<br />

Most Windows applications then produce a file with a .prn extension.This should<br />

be a PostScript file.You should probably rename it to be a .ps file.You should then be<br />

able to view it using GSview or another PostScript viewer, or create a PDF file using the<br />

ps2pdf utility.<br />

Be aware that different printer drivers produce PostScript output of varying quality.<br />

You might find that some of the PostScript files you produce give errors when run<br />

through the ps2pdf utility.We suggest using a different printer driver.<br />

If you intend to create only a small number of PDF files, Adobe’s online service<br />

might suit you. For $9.99 a month, you can upload files in a number of formats <strong>and</strong><br />

download a PDF file.The service worked well for our certificate, but it does not let you<br />

select options that are important for this project.The PDF created will be stored as a<br />

binary file <strong>and</strong> compressed.This makes it very difficult to modify.<br />

This service can be found at https://createpdf.adobe.com/.<br />

A free trial option is available for this service if you want to test it. Additionally, you<br />

can use the free service at http://www.acrobat.com if you have fewer than five PDFs to<br />

create.<br />

You can also check out a free <strong>Web</strong>-based interface to ps2pdf at the Net Distillery:<br />

http://www.babinszki.com/distiller/.<br />

A final option would be to encode the certificate in XML <strong>and</strong> use XML Style Sheet<br />

Transformations (XSLT) to convert it to PDF <strong>and</strong> any other desired formats.This<br />

method requires a good underst<strong>and</strong>ing of XSLT <strong>and</strong> is not covered here.<br />

Software to Create PDF Programmatically<br />

Support for creating PDF documents is available from within <strong>PHP</strong>. <strong>PHP</strong>’s PDFlib functions<br />

use the PDFlib library, available from http://www.pdflib.com/products/pdflibfamily/.<br />

PDFlib provides an API of functions to generate a PDF document.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!