I often get PDF documents that require some post-processing before I can distribute them. These documents contain internal links that allow readers to click on a graphic and quickly jump to another page or section of the same document. The graphics application that generates these PDFs uses embedded JavaScript to create and execute these links. I have been able to view these JavaScripts and see the code that performs these links.
One of the post-processing functions is to add a formatted page(s) into the documents, which I've automated with JavaScripts and is no problem. However, the embedded JavaScript internal links described above use the Acrobat 0-based numbering, so when I add the pages and Acrobat renumbers the document, the links are off by the number of pages I added.
I thought of two ways to correct the links: (a) renumber the 0-based page numbers, which I could not find a way to do [using non-negative numbers, nor setPageLabels, ... and others], or (b) edit the embedded JavaScript code to correct the "this.pageNum" commands to the right page. Trying (b), I edited the code and tried various ways to save it back to the original file, but it does not stay with the file after I close and reopen it. Acrobat even asks if I want to save the file before it closes, but upon reopening, the links are still broken.
How do I edit this embedded JavaScript and re-embed it into the original file so that the links are preserved? Or is there another way for me to correct the page numbering?
Thanks for any guidance.
Acrobat 9 Pro on XP