Two of my presentations covering PDF Portfolios and the new Rich Media Annotations are now available on AdobeTV. Each one is about an hour long. These presentations were recorded live so if the “um”s and “ah”s start making you crazy, you can get the same information by going to my home page and watching “Developing with ActionScript for Adobe Acrobat 9″ located in the “Recorded Presentations:” section in the left column.
Recently in PDF Portfolios Category
Flash in Acrobat: Part 1
Flash in Acrobat: Part 2
PDF Portfolios make the perfect companion for your holidays – downtime at the relatives, waiting for your delayed airplanes, or entertaining the kids. Why? Because we worked with Flash Games developers to create PDF Portfolios of their games.These portfolios are also great examples of what you can do with our new ActionScript API for Acrobat 9. So put down that Wii controller and go old school.
Actually, this post can apply to any large PDF that has any objects in it that might prevent the normal "Fast Web View" feature in Acrobat or Reader from displaying the PDF in the browser quickly.
Saving a PDF with "Fast Web View" restructures a PDF document for page-at-a-time downloading (byte-serving) from web servers. With Fast Web View, the web server sends only the requested page, rather than the entire PDF. This option is especially important with large documents that can take a long time to download from a server. For PDFs with static content like text, line art, and images this works great. You can browse through a PDF that’s thousands of pages very quickly without downloading the whole thing first.
“Fast Web View”, while functioning correctly, may not be effective when
loading PDF files containing large objects such as embedded videos or file attachments. To maintain backward compatibility, a PDF Portfolio is basically a PDF with a bunch of attachments and some extra stuff in the catalog object. When these kinds of files are encountered, Acrobat or Reader appears to hang when in reality it’s just reading a really big chunk of data from the server.
So back to the original question…
How Do You Deal with Large PDF Portfolios?
There are a number of ways, but here’s one that’s ridiculously easy if you have administrator rights to an Apache web server or even just a directory on it. By the way, this solution has nothing to do with Acrobat, Reader or PDF, it’s just basic server management.
Byte-Serving the PDF is fast. But… it’s not nearly as fast as just forcing the whole PDF to download rather than opening it in the browser. To do this, set the Content-Disposition to "attachment" for that file. On any web server, you can do this by serving the PDF up via a script and setting Content-Disposition in the HTML headers but with Apache it’s easier than all that. This may also work on other servers but I haven’t tried it.
I created two separate directories on my server. One called "view" and one called "download". In the "download" directory, I added a file called ".htaccess" that allows me to customize the server response to any request for a file from that directory. It contains a single line of code.
Header set Content-Disposition "attachment"
This allows me to create links to PDF files in the "download" directory and the end user will be prompted to download the file rather than have it open inside the browser. The following two links will behave very differently even though the <a href=> tag is basically the same and the PDFs are identical except that they are being served up from different directories. If you hover over the link, you’ll be able to see the destinations. The behavior is determined by the directory on the server, not any script or parameter in the <a href=> tag.
This PDF Opens in the browser – It’ll look like it hangs your browser but if you wait long enough it’ll show up.
This PDF will download to your desktop – You can open it once it’s finished. Personally, I think this is a better experience when “Fast Web View” won’t do the trick.
The Acrobat 9 SDK is posted to the Acrobat Developer Center for public download.
But wait, there’s more. New in Acrobat 9, we’ve added a livedocs version of the documentation. Now you’ll be able to provide feedback on most topics and even submit corrections or report bugs. Now’s the chance to show off your Kung-Fu skills and contribute to the developer community. Comments will be monitored so don’t expect them to show up right away but they will show up.
Flex Developer Alert!
Acrobat 9 Custom Navigator SDK is available in Pre-release:
Use Flex and your ActionScript skills to create SWF interfaces (Navigators) for PDF Portfolios using the new ActionScript APIs for Acrobat 9. Check out my previous post to see some of the possibilities. The good news is, the Custom Navigator SDK is all ActionScript, you don’t need to know anything about the rest of the Acrobat SDK to get started.
Use this PDF form to request access to the prerelease program.
Creating links from one PDF in a PDF Portfolio to another PDF in the same PDF Portfolio is really pretty simple but the “Preview” window is not the place to do it. The Preview Window does give you access to a few of the editing tools in Acrobat such as the commenting and link tools but, in my experience so far, saving your changes has proven to be unreliable. Don’t worry, there’s a work-around and I’ve already filed a bug report.
You’re much better off clicking the “Open” button to bring the file into the full Acrobat User Interface and creating your interactivity there.
Now you’ll be able to insert a link. In the link dialog, be sure “Go to a page view” is selected even if you are opening another file in the PDF Portfolio.
You’ll see the dialog below.
Your PDF Portfolio should still be open in a separate window, switch to it. Using the Portfolio navigation tools, go to the document you want to link to and click “Set Link”. You should be back where you started.
Be sure to save the file.
This entry is the second post on ensuring the user sees your PDF Portfolio in all it’s Flashy glory, that is, forcing it to be viewed in Acrobat or Reader 9. Earlier posts on this topic can be read
here Part 1, Part 2, and here Part 3.
With particularly large PDF Portfolios, this can potentially create a bad user experience when the user spends several minutes downloading a PDF only to find that they then need to go spend more time downloading a new Reader in order to view it. This article will discuss how to redirect the browser based on the version of Acrobat or Reader being used.
Redirecting the Browser Based on Viewer Version
The "right" way to do this is, unfortunately, unreliable. Ideally, you could have a PDF load into a small 1 x 1 pixel <DIV> and have Acrobat or Reader tell the browser what version it is. There’s enough of an API in Acrobat and Reader to make communicating with the host easy but there are too many dependencies on the most popular browsers out there to make this technique reliable. Instead, we’ll load a small, one page PDF into the browser and use it along with a parameter stored in the URL to redirect the browser to the actual destination.
The code might look like this.
q = this.URL.lastIndexOf("?")+1
destination = this.URL.substring(q)
if (app.viewerVersion >= 9)
//add a message here to tell the user what’s happening
//add a message here to tell the user what’s happening
Then you place the redirecting PDF on your site somewhere and create a link to it. In the link, add a "?" then the path to the actual destination. A live example URL and reference implementation is below.
The first two parts of this discussion focus on backward compatibility and creating a good user experience. If you are interested in that please read the earlier posts here Part 1
Part 2. This entry focuses on ensuring the user sees your PDF Portfolio in all it’s Flashy glory, that is, forcing it to be viewed in Acrobat or Reader 9.
if (app.viewerVersion < 9)
//Add your own message or something here.
Unfortunately, for security reasons, this.closeDoc() is not permitted to execute while a PDF is being viewed in the browser. To get around this limitation, I’ve also created a special link to the PDF that will prevent it from opening in the browser and ask the user to download it instead. This is also a great little trick to use for large PDF Portfolios that may take a long time to open in the browser.
The example file below will only stay open in Acrobat or Reader 9. If it is opened in an earlier version a dialog box (right) that I authored in WindJack’s AcroDialogs will appear explaining what’s happening.
This entry builds on concepts introduced in Part 1. Read it here:
PDF Portfolios and Backward Compatibility – Part 1
Many document authors who created PDF Packages in Acrobat 8 used the cover sheet to help users navigate the files in the package. Unfortunately, they ran into difficulties creating as dynamic an interface as they’d like given the limitations of the link actions in Acrobat 8. Based on their feedback, we added the PDF Portfolio feature to Acrobat 9 which lets developers leverage the power of Flash to create highly branded, highly interactive experiences for their document’s audience.
That said, many authors need their PDF content to be compatible with multiple versions of Acrobat. As mentioned in the previous article, the cover sheet can be replaced to create a more custom experience for users with earlier versions of Acrobat and Reader but that cover sheet can also serve as a navigational aide just like in Acrobat 8, it’s just that the authoring process in Acrobat 9 is a little different.
In Acrobat 8, you had full editing capabilities on the cover sheet. You could add buttons, links, bookmarks and other multimedia. In Acrobat 9 you only get the link tool and even that is only accessible through the menu, you won’t find it on the toolbar or the context menu.
To create an interactive cover sheet in Acrobat 9, follow the steps in the previous article to replace the default cover sheet then.
Add links to the PDF Portfolio cover sheet in Acrobat 9.
- Select View|Portfolio|Cover Sheet to show the cover sheet
- Select Tools|Advanced Editing|Link Tool to add links to the page
- Marquee over the area you want to be a link.
In the image below, I used PhotoShop CS3 to open the three PDFs, saved them as images (rasterizing the vector art and type) and added them to my PDF by editing the cover sheet in Adobe Illustrator CS3 then added links on top of those image areas to simulate the actions in a PDF Portfolio Layout.
- When adding links to other documents in the same PDF Portfolio, choose “Go to a page view” as the link action then use the detail view of the portfolio to go to the file you want.
- After setting the link, you’ll probably need to display the cover sheet again (Step 1)
This example file will display like the image below in Acrobat and Reader 8…
… and in Acrobat and Reader 9, you’ll see the normal PDF Portfolio view.
then come back here.
By default, PDF Portfolios created in Acrobat 9 will open in earlier versions of Acrobat and Reader and the PDF Portfolio will make the best use of the features available to it. When opened in version 8, the PDF Portfolio will act like a PDF Package and in version 7 and 6, the contents will appear as attachments. Since the portfolio layout is actually a SWF file and only Acrobat 9 can “play” it, earlier versions will display a “Cover Sheet”. The “Cover Sheet” was introduced in Acrobat 8 as part of the PDF Package concept and by default is a single page PDF that is used as a wrapper around a bunch of other content. However, in Acrobat 8, the cover sheet could also be a PDF of your own choosing with links and other navigational aides that you specify during the package creation process. This functionality has been replaced by the PDF Portfolio layout concept in 9 and now you do not have the option of setting your own cover sheet during the assembly process. The new default cover sheet looks like the one below.It’s not bad but you might want a more personalized experience for users that don’t have the latest version. To customize the cover sheet, follow the instructions under the graphic.
Replacing the default cover sheet with your own.
Create a PDF file with all of the information you want to convey to users of earlier versions of Acrobat
Open the PDF Portfolio that you want to customize
Select View|Portfolio|Cover Sheet from the menu. You should see the same thing as above.
Select Document|Replace Pages and select the PDF that you just created and follow the rest of the dialog prompts.
- Save the file.
Now users of Acrobat or Reader version 9 will see the animated portfolio layout and users of earlier versions will see your custom cover sheet.
Setting the default cover sheet.
Replace the file called “coversheet.pdf” in your version of this directory “C:\Program Files\Adobe\Acrobat 9.0\Acrobat\DocSettings\CombineFiles\ENU” and that will be the new default.