Adobe LiveCycle Designer: Working with PDF and Acrobat
- There is no such thing as fun for the whole family.
- —Jerry Seinfeld
Portable Document Format (PDF) is actually a family of file formats, and this chapter focuses on the ones that are relevant to LiveCycle Designer. You’ll learn how to create these various types of PDFs and understand how and why to use each one. All these types work best in the premier client tool for viewing and working with PDFs—Adobe Acrobat.
Like PDF, Adobe Acrobat is a family with many members. It’s important to understand the features of the various Acrobat programs because their features affect how your PDF forms function. Acrobat has the agility to run as a standalone application or as a plug-in to your web browser, and it gracefully balances these two modes. It can also handle the requirements of different types of users working with different types of PDFs. And it works on virtually every computer system and renders PDF files faithfully and efficiently regardless of the system’s fonts and software.
Although Acrobat is the ideal tool, there are also many non-Adobe PDF viewers on the market. If you’re deploying PDFs to a heterogeneous user base, you need to know how your PDFs will perform in these third-party tools.
The PDF Family
The term PDF refers to a family of file formats and an evolving set of technical specifications. Many of these formats and specifications are International Organization for Standardization (ISO) standards, and some are specific intellectual property owned by Adobe.
XFA PDF (PDF Form)
Adobe uses the term PDF form to refer to the interactive and dynamic forms you create with Designer. It’s important to note that there’s another type of PDF form, called an Acroform, that’s different from the PDF forms you create in Designer. The forms and files you create with Designer are based on Adobe’s XML Forms Architecture (XFA). In many ways, the XFA PDF file format is closer to an HTML file than it is to a traditional PDF file. For instance, the following code shows you what a simple text object looks like in an XFA PDF file:
<draw name="StaticText1" y="15.875mm" x="28.575mm" w="29.2864mm" h="5.2331mm"> <ui> <textEdit/> </ui> <value> <text>Text</text> </value> <font typeface="Myriad Pro"/> <margin topInset="0.5mm" bottomInset="0.5mm" leftInset="0.5mm" rightInset="0.5mm"/> </draw>
As you can see, XFA forms are XML based. This well-structured and flexible format enables a LiveCycle Server to transform your Designer files into many different formats, including traditional PDF and HTML. You can see the complete XML structure of your forms in Designer by selecting the XML Source tab of the Layout Editor. As you learned in Part 1, “The Designer Tool,” all the objects and events in these XFA PDFs are scriptable at runtime, so this PDF type offers you a great deal of flexibility and power. You can create both static and dynamic XFA forms in Designer.
Static forms
Static XFA PDF forms won’t change their layout at runtime, but they can be interactive for the user. The following are a few advantages of static XFA PDF forms:
- Static forms support Acrobat’s Comment and Markup tools.
- Static forms enable you to import and export Acrobat comments.
- Static forms support font subsetting, which you will learn about in the next chapter.
- Static forms work in early versions of Acrobat like 6 and 7, but dynamic forms are recommended only for version 8.1 and above.
You can create a static XFA PDF in Designer with the SmartDoc Expense Report form that you developed in Chapter 3, “Creating the SmartDoc Expense Report.” Follow these steps to create and view a static PDF form:
- Launch your Designer program, and open the expenseReportCompleted.xdp file from the Samples folder.
- Select File > Save As to open the Save As dialog box.
- Enter expenseReportStatic.pdf as your filename, select Adobe Static PDF Form (*.pdf) as your file type, and click Save.
- Launch Adobe Acrobat from the Windows Start menu. Please note that if you’re using the free Adobe Reader program, you won’t yet be able to use the commenting tools because this file has not been Reader extended. You’ll learn how to do this in an upcoming exercise.
- Select File > Open and browse to the static PDF you just created.
- Click the Add Expense button on the form. Notice that a new row is not created because this isn’t a dynamic PDF.
- Open your Comment tools and notice that you can add comments to this type of PDF because it’s a static form.
Dynamic forms
Dynamic XFA PDFs can change their layout at runtime, so the commenting and markup features aren’t supported. However, dynamic XFA PDFs do offer the following advantages:
- Dynamic forms support client-side scripts that change the layout and pagination of the form. For instance, your SmartDoc Expense Report will expand and paginate to accommodate an endless amount of data if you save it as a dynamic form.
Dynamic forms support all the properties of your form at runtime, whereas static forms support only a subset (Figure 4.1).
Figure 4.1 In static forms (top), you can change only the background fill of your text field at runtime. Dynamic forms (bottom) enable you to change almost any property of your form at runtime.
Follow these steps to create and view a dynamic PDF form:
- Go back to your expenseReportCompleted.xdp file in Designer.
- Select File > Save As to open the Save As dialog box.
- Enter expenseReportDynamic.pdf as your filename, select Adobe Dynamic XML Form (*.pdf) as your file type, and click Save.
- Launch your Adobe Acrobat or Adobe Reader program from the Windows Start menu.
- Select File > Open and browse to the dynamic PDF you just created.
- Click the Add Expense button on the form. Notice that a new row is added because this is a dynamic PDF.
Open your Comment tools and try to add a comment. Notice that you can’t add comments to this type of PDF form (Figure 4.2).
Figure 4.2 Acrobat’s commenting features don’t work on dynamic PDF forms.
If your Designer form works equally well as either a static or dynamic XFA PDF form, Adobe recommends creating dynamic XFA PDFs for performance benefits.
PDF File (Traditional PDF)
The most popular and pervasive PDF format is the traditional PDF file. There are many ways of creating a traditional PDF file, including using Acrobat and many third-party tools. Acrobat provides all the following ways to create traditional PDF files. If you don’t have Acrobat installed, you may not see these options on your computer.
- By capturing the print stream of a desktop application: Choose the Print command of an authoring application and select the Adobe PDF printer icon. Instead of a printed copy of your document, you’ll have created a PDF file of your document.
- By using the Acrobat PDFMaker plug-in with Microsoft Office applications: When you install Acrobat, it adds an Adobe PDF menu to Microsoft Office applications and an icon to the Office ribbon. You can use these added features to create PDF files directly in Microsoft Office.
- By using Acrobat Distiller to convert PostScript and Encapsulated PostScript (EPS) files into PDFs: Distiller is typically used in print publishing and other workflows that require a conversion from the PostScript format to the PDF format.
Static documents
Under the hood, a traditional PDF is very different than an XFA PDF. It doesn’t have the same XML structure, and since it’s created by capturing the print stream of a file, a traditional PDF is a static and read-only file. You can create a traditional PDF file from a dynamic Designer file by following these steps:
- Launch your Designer program, and open the dunningNotice.xdp file from the Samples folder.
- Select File > Form Properties > Preview.
- Select Print Form (One-sided) as your preview type.
- Locate a data file by clicking the Browse button to the right of the Data Field entry field.
- Select dunningNoticeData.xml from the Samples folder and click Open.
- Select Dynamic XML Form as your preview type.
- Click OK to save these preview settings.
- Select Preview PDF to see your dynamic form merged with your data file. At this stage, your PDF is still an XFA PDF.
Press F8 on your keyboard to display the Acrobat toolbar (Figure 4.3).
Figure 4.3 The Acrobat toolbar in Designer’s Preview PDF tab. If you click Save A Copy, you’ll create an XFA PDF. If you click Print File, you’ll create a traditional PDF.
- Click the Print File button. Select Adobe PDF as your printer, and click the Print button on the bottom right.
- Enter dunningNoticeTraditional.pdf as your filename, and click Save. You have now created a traditional PDF file by capturing the print stream of your XFA PDF file. This new PDF file is static and read-only.
Dynamic documents
Since the source file for the Dunning Notice is a dynamic Designer file, the rendered files will grow or shrink based on the length of your data (Figure 4.4). There are additional data files in the Samples folder, and each has a different amount of data. You can repeat the steps in this exercise with these data files to see how different PDFs will be created each time. This is an example of dynamic document generation.
Figure 4.4 The Dunning Notice is a dynamic Designer file that will grow or shrink to accommodate the data that’s merged with it.
Acroforms
Acroforms are Adobe’s older interactive form technology; they date back to Acrobat version 3. Adobe provides the Acrobat Forms API Reference, dated May 2003, to provide the technical details for this technology. You can find a link to this on the book’s companion site. Acroforms are a combination of the following items:
- A traditional PDF that defines the static layout and graphics of the form.
- Interactive form fields that are bolted on top with the form tools of the Adobe Acrobat program. Please note that these form tools are a small subset of what’s available in Designer.
Acroforms can be enhanced and expanded with Designer. However, even when you enhance an Acroform in Designer, it’s still a traditional PDF under the hood, and there are limits to how interactive and dynamic you can make these forms. For instance, only some of the form fields in Designer’s Object Library are supported in Acroforms, and even the ones that work are only partially supported.
To move beyond the limits of Acroform technology, Adobe has invested in XFA to provide an XML form structure that’s both interactive and dynamic. If you’re moving from Acroforms to XFA PDFs, you need to know a couple of important facts about these two technologies:
Designer can edit a PDF form created in Acrobat, but Acrobat cannot edit a PDF form created in Designer.
- JavaScript works differently in these two technologies. Some of the JavaScript routines that work in Acroforms won’t work in XFA forms. Adobe has documented these differences in a 43-page online PDF called “Converting Acrobat JavaScript for Use in LiveCycle Designer Forms.” You can find a link to this on the book’s companion site. As mentioned previously, Designer is a much more robust tool for using JavaScript in your forms, so I recommend that you learn how to script in Designer with the XFA object model.
PDF/A
PDF/A (PDF for Archives) builds on the document storage benefits of traditional PDFs with many specific details that enhance long-term archiving. The traditional PDF file format offers many benefits for long-term document storage. The compact nature of PDF facilitates easy transfer and conserves space, and its well-structured nature enables powerful indexing and search capabilities. Traditional PDF has extensive support for metadata, and PDF has a long history of supporting many different computer environments.
Like PDF, PDF/A is an ISO standard specification. It was developed by a task force that included AIIM (Association for Information and Image Management), NPES (National Printing Equipment Association), and the Administrative Office of the U.S. Courts. Since the goal of the PDF/A specification is to provide a long-term archive format, many PDF features are omitted so the files can be self-contained. The following are some key points about the specification that enhance the long-term reproducibility of the PDF/A file:
- All content must be contained in the file, and there can be no dependencies on external sources like hyperlinks, fonts, or software programs.
- All fonts must be embedded, and they need to be fonts that have an unlimited-use license for electronic documents.
- JavaScript isn’t allowed.
- Transparency isn’t allowed.
- Encryption isn’t allowed.
- Audio and video content aren’t allowed.
- Color spaces must be defined in a device-independent way.
- All metadata must follow certain standards.
Different PDF/A versions
Although the original standard was based on Adobe’s PDF Reference Version 1.4, the ISO technical committee maintains the specification and has created the following versions:
- PDF/A—1b: This level is based on PDF version 1.4, and it ensures that the file can be accurately reproduced visually on a computer system in the future.
- PDF/A—1a: This level is also based on PDF version 1.4, and it includes all the requirements of 1b plus some additional requirements to ensure the long-term reproducibility of the document’s text stream in other devices besides a traditional computer.
- PDF/A—2: This is a newer specification (released 2011), and it addresses some of the new features in PDF versions 1.5, 1.6, and 1.7.
- PDF/A—3: This is the newest specification (released 2012), and it allows embedding of compliant archived objects, including XML, word processing, and spreadsheet documents.
Viewing a PDF/A file
Two files in the Samples folder were created from the same Microsoft Word file. One was created as a traditional PDF and the other as a PDF/A file. Open these two files in Acrobat Professional:
- simpleWordFile.pdf
- simpleWordFilePDFA.pdf
Although the documents look the same, the PDF/A file opens with a blue bar across the top, indicating that you’re viewing this document in PDF/A mode. This blue bar is Acrobat’s document message bar (Figure 4.5), which you’ll see when you open certain types of PDF files.
Figure 4.5 Acrobat’s document message bar highlighted in blue.
The document message bar includes instructions, and possibly buttons, to help you complete a task. It’s color coded, and you’ll see the blue color when you open special types of PDFs (like this PDF/A file) as well as certified and digitally signed PDFs. The bar changes to purple for PDF forms and to yellow when you’re participating in a PDF review.
This message bar indicates that your file conforms to the PDF/A specification. Another compliance indicator is found in the Results pane of Acrobat Professional’s Preflight tool. Follow these steps to see how it works:
- Open the simpleWordFilePDFA.pdf file in Acrobat Professional if it isn’t already open.
Choose Tools > Print Production > Preflight to open the Preflight dialog box (Figure 4.6). If you don’t see this option, select the Show Or Hide Panels option in the Tools drop-down in the upper-right corner of the Tools panel.
Figure 4.6 The Acrobat Preflight tool shows you various PDF/A profiles that you can test your file against.
- Scroll down to the PDF/A compliance section and select Verify Compliance With PDF/A-1b.
Click the Analyze button at the bottom of the dialog box. Acrobat will compare your file to the PDF/A-1b profile and issue a report (Figure 4.7).
Figure 4.7 The Acrobat Preflight tool shows you the results of the analysis.
If you go back to the Profiles tab and compare your file against other PDF/A profiles, you’ll find that it doesn’t meet all requirements. You can also open simpleWordFile.pdf and see the issues that this file has. Experiment with the features of this tool. In many cases, you can use the Convert To PDF/A options to make your PDFs compliant with the various specifications. In some cases, you’ll need to go back to the source files of your PDFs and make changes in order to reach compliance. LiveCycle Server can automatically convert your Designer files into PDF/A documents.