Update Bookmarks to Reflect New Page Positions
I made the following post a few days ago: Re-Order Pages to Match Bookmarks, but I have now run into a different problem related to the same project. I was able to get the pages re-ordered to match the order of the bookmarks by doing the following:
- Loop through all bookmarks that have a "GoTo" action
- Add each page to a new PDDocument object in the order that the bookmarks appear
PDDocInsertPages(newDocument, moveAfterPage, originalDocument, currentPageNumber, 1, includeFlags, NULL, NULL, NULL, NULL);
- Replace the pages in the original document with the correctly ordered pages in the new document
PDDocReplacePages(originalDocument, 0, newDocument, 0, PDAllPages, true, NULL, NULL, NULL, NULL);
However, now that the pages have been re-ordered, the destination page for each bookmark is incorrect. I have pages labeled 1 through 10. I moved page 7 to be the second page in the document, so the order is 1-7-2-3-4-5-6-8-9-10. But now the bookmark for "page 7" still points to the page at position 7 (which is now the page labeled "6") rather than pointing at the page labeled "7" (which is now the second page in the document).
Is the problem coming from the way that I re-ordered the pages in the 3 steps listed above?
Is there a way to force the bookmarks to update their destination as a page is moved to a new position?
Or is there a way to manually update the destination page for a bookmark when I move the page to a new position?
I have looked in the Acrobat API documentation, but I have not been able to find a way to do either of these.
