Copy link to clipboard
Copied
Last week I asked for help on a script to delete non-annotated pages and immediately got help from the MVPs. The suggested fix worked perfectly but I soon realized my flawed strategy. The documents I want to process consist of two or three thousand pages, grouped with many top level bookmarks that are also named destinations. Since I search and highlight keywords and then delete pages without annots, it so happens that sometimes, a page with a top level bookmark is deleted and then leaves no link to the children pages beneath it. So, I'd like to add a condition to the script to check whether the page has children. The top level bookmarks are 7 digit numbers and the children are Page 2, page 3, and so on. The Acrobat reference says 'children' returns an array but I'm confused. I tried the following code but then nothing gets deleted. Thank you guys SO MUCH for the time you put in to this forum. I have learned so much from reading answers to others questions.
1 Correct answer
The only way you can get the page numbers to which the bookmarks are pointing is to execute the bookmarks (using the execute method of the Bookmark object -- forget about annotations, they are not related), and then check the current page number (using the pageNum property of the Doc object).
There's no way to get a list of Named Destinations or where they are placed using JS.
Copy link to clipboard
Copied
Pages don't have children, bookmarks do. bookmarks and pages are separate, they do not own each other.
Read ad your code carefully. If there are no bookmarks if deletes all pages with no Annots. If there are bookmarks (if the bookmark root has children) nothing is deleted. I dont quite understand what you want but I think you are looking for something that is not only not automatic, but nonexistent.
Copy link to clipboard
Copied
Ok, I'll try to better explain what I am trying to do. I have large PDF files of 3000-4000 pages (product assembly information). All pages are bookmarked. All pages have named destinations that were created from the bookmarks. Bookmarks are arranged/named by major group (7 digit number) and subgroup (page 2, page 3 etc.) There are links on a web page that point to each major group destination.
I use this script, combined with the 'Find and Highlight' action, to find, highlight pertinent model numbers and delete pages that are not annotated. What I'm trying to do is KEEP ALL pages that are destinations for a major group(even though some may get annotated). Since you say that there is no correlation between bookmarks and pages, is there a way I could get the information that is presented in the destinations panel (destinations sorted by name and corresponding page number) so that I could remove those pages from the pageArray if they exist? or even prevent them from being pushed to the array?
Copy link to clipboard
Copied
The only way you can get the page numbers to which the bookmarks are pointing is to execute the bookmarks (using the execute method of the Bookmark object -- forget about annotations, they are not related), and then check the current page number (using the pageNum property of the Doc object).
There's no way to get a list of Named Destinations or where they are placed using JS.

