Home
eMail

If you're seeing something other than Verdana, the Font is Graublau Sans Web by FDI fonts.info

Creating Custom PDF Portfolio Layouts
Updated 11/13/2009

Part 5: Sorting items in a PDF Portfolio

This article explains how to add the necessary code to your Navigator to sort items in a PDF Portfolio.

By default, the initial sort is based on the "Name" field which corresponds to the filename of the IAttachment in the PDF Portfolio. However, you can use the "Specify File Details" panel to set the initial sort to whatever you like (see image to the right). You can even add your own custom metadata fields through this interface or, as I discussed in my previous tutorial, you can add fields through the "Navigator.xml" file.

What You'll Need to Get Started:

The following is a list of software that you'll need to get started with these tutorials. This section is repeated in each article on this topic.

What You Need: Where to get it:
Adobe Acrobat 9 Pro or
Adobe Acrobat 9 Pro Extended
If you don't already have a copy of Acrobat, you can buy it here. For Windows users, you can download a fully functional 30 day trial here. Sorry - we don't have a trial version for OSX.

Flex Builder 3 You can purchase or download a 60 day free trial of Flash Builder 4 here

Note: The Actobat ActionScript API (AcrobatAPI.swc) only works with version 3.0.0 of the Flex SDK. You can download version 3.0.0.477 of the Flex SDK here. The project files in these tutorials will be looking for the name "Flex 3.0.0" in the compiler settings.
The Acrobat 9 ActionScript SDK You can download the complete Acrobat 9 SDK here. The Navigator SDK is part of that.
Apache Ant Again, I like to keep everything in Flex so I use Flex Ant Tasks to zip my files into a Navigator .NAV file. Instructions on how to set this set up are in the next part of the series.

The Obvious and the Hidden:

The list view (second icon below) of a PDF Portfolio is a completely separate Navigator. This means that everytime a user switches between list view and the Home (first icon below) view, your Navigator is restarting. It is not required but, ideally, your Navigator will account for any changes that were made to the sort order when the user was in the list view. To accomplish this, your Navigator will need to check the sort order when it starts up.

Here are a few things to keep in mind when implementing sorting in your Navigator.

  • The initial sort order of the PDF Portfolio is a property of the Collection, not of the Navigator. You can decide to either ignore the sort order specified in the PDF file or work with it. If you plan to ignore it, you can stop reading this article... but then you'd miss all the fun.
  • The order of the items in the Collection has nothing to do with the sort order. You'll need to detect the sort order and apply it to the Collection every time the Collection changes. The good news is, it's pretty simple to do once you understand the rest of these bullets.
  • When looking at a PDF Portfolio in the list view, you can sort the portfolio by clicking on the different column headings and can toggle them to be ascending or descending. What the interface does not tell you is that the clicks are assembling an array of sort criteria. If you are looking at the list view and the initial sort order is "Order" then you click on "Name" and then "Modification Date", your new sort order is the reverse of your clicks back to the initial sort; so it becomes "Modification Date", "Name", "Order". Click on "Order" again and the sort order becomes "Order", "Modification Date", "Name".
  • As of Acrobat 9.1, if you change the sort in the list view while in edit mode (the "Edit PDF Portfolio" panel is open), the initial sort is reset to that field and the file will be saved with the selected field as the new initial sort. If you are not in edit mode, the sort order will remain unchanged at the file level and when you switch back to your Navigator view, the sort will not be updated based on the list view. Basically, when you are in edit mode, your changes immediately affect the file. When you are not in edit mode, the changes to the sort order are for presentation only.

The Flex project linked to below demonstrates how to determine the sort order of the PDF Portfolio and then how to apply the sort order to the Collection. It also shows how to check if the file can be modified and then set the sort order to whatever you like if that's allowed.

The sort order is determined by the collection.sort array which is an ordered array of ISort instances.The collection.sort property is read/write so it's pretty easy to have your Navigator set the sort order. When sorting the items in the Collection, you also need to be cognizant of the field type in the ISort object. You'll see in the Flex project where I detect text, numeric and date types so that I can apply the correct type of compare function when sorting.

Conclusion:

Download this PDF file and try switching between the home view and list view and changing the sort order. If you have Acrobat 9, try doing it whith the edit panel open and closed and see what happens to the sort order to better understand the concepts in this article.

After downloading this example and compiling the code, you can install the Navigator by following these simple steps.

Installation:

Windows:

  1. From Windows, select "Start" then "Run". Paste the following line into the text box and press enter

    %USERPROFILE%\Application Data\Adobe\Acrobat\9.0\

  2. Create a directory called "Navigators" if you don't already have one
  3. Drag the "_01_HelloWorld.swf" file to the "Navigators" directory
  4. Restart Acrobat if it's running.
  5. In the "Edit PDF Portfolio" panel you should see an "Other Layouts" category in addition to "Basic Layouts"
OSX:
  1. Browse to /Application Support/Adobe/Acrobat/9.0_x86 in your user Library folder
  2. Create a directory called "Navigators" if you don't already have one
  3. Drag the "_01_HelloWorld.swf" file to this location in Finder.
  4. Restart Acrobat if it's running.
  5. In the "Edit PDF Portfolio" panel you should see an "Other Layouts" category in addition to "Basic Layouts"

Files:
Download Source

Comments: