Document Compare found too much – JavaScript to the Rescue

| 9 Comments

I got an interesting request from Rick Borstein who is one of our Acrobat Product Specialists. It seems that one of his customers is using the new Compare Documents feature in Acrobat 9 for long legal documents. This is actually a perfect use case for this feature but the customer is hampered by the fact that Compare Documents can sometimes find too much. As a text heavy legal document, they don’t have much need for the per pixel differences in graphics and certainly don’t need to see “Matching graphic not found” beside every change bar.

The customer was either looking for a way to “tune” what Acrobat was looking for, which will need to wait for the next release, or simply have an easy way to remove the change indicators that they don’t need. The one tricky part was that they wanted a user interface (UI) to delete all of the change indicators that matched a different set of criteria. I’m not much of a UI designer and even with Windjack’s Acrodialogs plug-in, creating a UI in Acrobat JavaScript would have turned this fun experiment into…. well…. work!

Background:
When Acrobat 9 compares documents, the change indicators that it creates are actually annotations. The Acrobat JavaScript API has been able to manipulate annotations since version 5.0 and that part of the API has evolved quite a bit since then. Because you can ask Acrobat JavaScript to collect the annotations into an array and filter them based on a variety of criteria, it doesn’t require a lot of code to grab all of the annotations in a document and process them; “for” loops can be a lazy programmers best friend.

The Script:
By installing the JavaScript in a folder at the application level, I was able to add a menu item that makes this simple script behave like an Acrobat feature available to any document.

To solve the UI problem, I decided write the script so that it could detect which annotation was selected, determine it’s properties and then look for more just like it. That way the user just needs to select an annotation, choose my menu item "Delete Annotations of the Same Type and with the Same Content as the one Selected" and all that’s it. No UI required.

The links in the bullet list will take you to the appropriate section of the Acrobat JavaScript Reference.

The example demonstrates

This JavaScript will add a menu item “Joel’s Comment Utilities” under “Comments” menu.
Under that menu, you will find three additional menu items.

  • Delete “Matching graphic not found” Annotations
    This menu item will delete all “Highligh” annotations with content “Matching graphic not found”

  • Delete Annotations of the Same Type and with the Same Content as the one Selected
    To use this menu item, select one of the type of comment that occurs frequently that you want to remove all of then select the menu item.
    All comments of the same type and same content will be deleted.

  • Count Annotations of the Same Type and with the Same Content as the one Selected
    Same as above except that comments are not deleted, they are simply counted.

Installing Joel’s Comment Utilities
1. Quit Acrobat if it is already running
2. Download “Joel’s Comment Utilities” and then copy the ADBE_JFG_RemoveMatchingAnnots.js file into the following file location:

a. WIN XP
C:\Documents and Settings\Administrator\Application Data\Adobe\Acrobat \9.0\JavaScripts

b. WIN VISTA
C:\Users\USERNAME\AppData\Roaming\Adobe\Acrobat\9.0\JavaScripts

c. MAC OSX
/Users/YOURUSER/Library/Application Support/Adobe/Acrobat/9.0_x86/ JavaScripts

3. Restart Acrobat

Using the Reduce Comments Script
1. Open a PDF containing comparison comments
2. Choose one of the following commands:

a. Comments | “Joel’s Comment Utilities” | Delete Matching Graphic Not Found Comments
    – or -
b. With another type of comment selected, choose:
Comments | Joel’s Comment Utilities | Delete Annotations with same content as one selected