home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeWeb Design in a NutshellSearch this book

5.4. Portable Document Format (PDF)

PDF (Portable Document Format) is a technology developed by Adobe for sharing electronic documents. The remarkable thing about PDF files is that they preserve the fonts, colors, formatting, and graphics of the original source document. Ideally, a PDF document looks exactly the way it was designed, regardless of the platform, hardware, and software environment of the end user. It can be viewed on the screen or printed out to a high-quality hard copy.

PDF existed before the Web, but the two make great partners -- PDF is the ideal file format for sharing documents, and the Web provides a highly accessible network for distributing them. You can make any document into a PDF file and make it available from a web page. The advantage, of course, is that you have more control over fonts and layout, and the formatting is not limited by HTML.

Forms, documentation, and any other materials that rely on specific formatting are good candidates for PDF files. To use a classic example, the IRS makes tax forms available for download in PDF format so taxpayers can print them out at home without requesting them by mail or making a trip to the post office.

But PDF files are not totally static. They can contain links to online material and other PDF files. Adobe Acrobat 5 can even create interactive PDF forms which can be filled out, automatically updated, and submitted online. PDFs can also be dynamically generated based on user input.

With the control PDF offers over display, it's tempting to want to use it for all online material. It's important to understand that PDF is not a substitute for HTML, nor is it likely ever to be. But it is a powerful tool for sharing any sort of document electronically. It's like sending a piece of paper through the lines.

5.4.2. Creating PDF Files

The standard application for creating PDF files is Adobe Acrobat, which is in Version 5 as of this writing. This commercial product gives publishers the greatest control over PDF creation.

When Acrobat is installed on a computer, making PDFs is simple. From an Adobe application, just open the document and export it to the PDF format. In Microsoft Office (Windows only), there is a PDF Maker icon right on the toolbar. To create a PDF from a non-Adobe application, print it to a PostScript file (choose "File" instead of "Printer" in the Print dialog box). Then open the PostScript file in Acrobat Distiller (part of the Acrobat package) and save it as a PDF file. In both scenarios, a dialog box appears, in which you can specify a large number of quality and optimization settings.

Once the PDF file has been created, it can then be opened in Acrobat for further fine-tuning and advanced settings. See the Adobe web site (http://www.adobe.com) or the Acrobat documentation for more information on creating and fine-tuning PDF files.

The important thing to remember is that the PDF file needs to be optimized for web delivery, so be sure to check the "Optimized" box in whatever program you use to create your PDFs. Optimizing the PDF structures the document and the media it contains so that it can be delivered page by page. It also results in much smaller file sizes. When you save the PDF, be sure that you give it the proper .pdf suffix.

Alternatives to Acrobat

Acrobat is not your only option for converting your files to PDF. Because PDF is an open source technology, Adobe has opened the door to third-party developers who want to support the ability to create PDFs. These include shareware programs, Perl scripts, and even printer driver-based tools that fool your programs into thinking they are printing to a printer, when in fact they are creating a PDF file. A good place to look for PDF-related tools is PlanetPDF (http://www.planetpdf.com).

There are also online conversion services: you upload your file and it is converted for you for a small fee or subscription. Adobe has its own conversion service called Create Adobe PDF Online that charges a monthly fee, but your first three conversions are free. It is available at http://cpdf.adobe.com. Even better, check out Gohtm.com (http://www.gohtm.com), where they convert your documents to PDF for free!

These services may be a good alternative if you only need to create PDFs occasionally. If you plan to make PDFs part of your publishing process, Acrobat is a good investment because of the advanced features it offers.

5.4.3. HTML for Adding PDF Files to Web Pages

There are two basic ways of calling a PDF file from a web page: linking to the file (or a specific page within it) and embedding it in the page like an image.

5.4.3.1. Linking to a PDF file

Creating a link to a PDF file is the same as linking to any other document. Just include the file name in the URL as shown in this example:

<A HREF="documentation.pdf">Link to PDF file</A>

The PDF file resides on the server like any other media file. Most modern server software is preconfigured to recognize the PDF MIME type (type application/pdf, extension .pdf).

5.4.3.2. Linking to a specific page in a PDF file

It is possible to create a hypertext link to a specific page in a PDF document, allowing readers to jump just to the relevant information without waiting for the entire PDF document to download. It's a useful feature, but a number of criteria must be met in order for it to work:

Assuming all these elements are in place, it is easy to create the PDF and link to it. With the PDF document open in Acrobat, create a new destination at the page you want to link to and give it a logical name (e.g., section3). Add destinations with the Destinations palette (Window Figure 5.4.3.2 Choose Destinations). Repeat for additional destinations. When you save the PDF file, be sure to check the Optimized checkbox. Optimizing the PDF file structures it page by page.

In the HTML document, make a link to the PDF file and the specific destination. The section name is separated from the file name by a hash symbol (#), as shown in this example:

<A HREF="article.pdf#section3">

For more information on page-serving PDF files, see the Adobe.com tutorial at http://www.adobe.com/epaper/tips/acrlongpdf/main.html. For more technical information about byteserving, see http://www.adobe.com/support/techguides/acrobat/byteserve/byteservmain.html.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.