The Notepad is old and grody

Quickly apply “Inherit Zoom” to all bookmarks in a PDF file

Scribbled  · PDF · ◊Pollen source

I often compile PDF reports totaling 1,000 to 2,000 pages, and am always creating hierarchical bookmarks for these files. One of my beefs is that often, clicking a bookmark will change the magnification setting to “fit width” from whatever you had it set at. Ideally, clicking a bookmark should default to just leaving the zoom level at whatever the reader is currently set to use (“Inherit zoom”). I’ve found no way in Acrobat to set the default behaviour for newly-created bookmarks, and changing these links one at a time in Acrobat is extremely tedious.

Thankfully, there is a solution provided by Martin Backschat:

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 save 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.

I don’t have UltraEdit but I was able to make this work using Notepad++. The exact search/replace text was slightly different for my PDF files (note the added space) but the principle is the same:

  1. In Notepad++, click the TextFX menu, then TextFX QuickFind/Replace (the standard find/replace tool will not help you here). Make sure you check the “Regular Expr” check box on the right.
  2. Use R/XYZ(.*)] as your search string and R/XYZ] as your replace string and replace all instances.
  3. Do it again using R/Fit(.*)] as your search string and the same replace string as above.

Responses

RobMay 27, 2011

Hey I tried this using Notepad++ on a pdf that has a bunch of bookmarks with different zoom levels. The find/replace didn’t find any matches to the strings.

RobMay 27, 2011

This was using the TextFX find/replace. Any suggestions to get it to work? It would be great if I could get it to work

ShaneJune 24, 2011

Thanks for the tip. For the folks running into trouble with Notepad++, just remove the space between the “R” and “/” in “R /XYZ(.*)]”, it should be “R/XYZ(.*)]” same thing applies to the repalcement text.

JoshuaMarch 01, 2012

I couldn’t get it to work using Notepad++, but came up with another solution using JPDFBookmarks…

Daniel KrausJanuary 11, 2014

I wrote a small java application which is based on the PDF Clown library. It allows you to easily apply various bookmark configurations, such as ‘Inherit zoom’, to multiple PDF files within a desired directory.

This is my first public project and due to the fact that I’m taking my exams in the next couple of weeks, I’m running out of time. But afterwards, which should be in mid-February, I’ll keep on developing.

In the meantime, feel free to use the application and give some feedback.

Werner HeckelMarch 21, 2014

Thanks Daniel. Your tool was a great help.

N. JonesMay 27, 2014

Daniel,

Thanks for the java app. It works like a charm! Great time-saver too.

SergioUrraAugust 03, 2014

@Joshua, thanks a lot. I did use JPDFBookmarks. Really nice app.

Jonnie TylerAugust 19, 2015

Thank you Daniel!