Update note: Here’s a more recent blog posting on PDF hacks. All scripts, including the ones mentioned above, are contained in the ZIP archive with perl scripts
I found out that you can do – quite simply – two very useful hacks on PDF documents with bookmarks:
Apply “Inherit Zoom” to all Bookmarks
I like to see, by default, the whole page, and set this accordingly in my Acrobat preferences. Some bookmark links, when clicked, modify the current zoom settings, e.g. put you in 100% or worse, in 200%. To modify this annoyance you can directly modify the PDF document in your Text editor.
With UltraEdit, for example, I load the PDF document and open the “Search and Replace” box, enable “Regular Expressions” and replace all occurrences of “R/XYZ*]” with “R/XYZ]”, and then also all occurrences of “R/Fit*]” with “R/XYZ]”. Now safe the document.
With the Perl scripting language, this hack is applied with
perl -pe 's#R/(XYZ.*?|Fit.*?)\]#R/XYZ\]#g#' in.pdf >out.pdf
The next time you open the modified document with Acrobat you will get a message that the document is being repaired. Just safe it again with Acrobat and everything is fine.
Close all Bookmark Folders (recursively, nested)
Unfortunately, PDF documents with a huge folder hierarchy of bookmarks have all folders opened. This creates a large list and I cannot find anything at glance. How can I close all folders, also the nested ones? To modify this annoyance you can directly modify the PDF document in your Text editor.
With Search and Replace, for example, I specify the PDF document, enable “Regular Expressions” and replace all occurrences of “\/Count +[0-9]\/Parent” with “/Count -%1/Parent”.
With Perl, this hack is applied with
perl -pe 's#/Count ([0-9]+)/Parent#/Count -$1/Parent#g#' in.pdf >out.pdf
The next time you open the modified document with Acrobat you will get a message that the document is being repaired. Just safe it again with Acrobat and everything is fine.
Note: Always make a backup of your PDF document before modifying it, since sometimes the hacks just don’t work and you end up with a document that Acrobat cannot repair.