I have a pdf document that has multiple bookmarks within it, so for example multiple chapters of a book and each chapter has a cover page.
There are many chapters so just inserting a page manually is not quite feasible and the pdf is coming out of a reporting system that we can't change to force it to add an extra page.
yes it's possible, provided you're opening it in Acrobat and not Reader - however it's a nasty code to write as there's no inbuilt way to read the destination page number of a bookmark using the API.
I don't have a script to hand for your specific case, but the pseudo-code for a batch process command would be along the lines of;
- load the bookmarks using the doc (this).bookmarkRoot object and traverse through the children thereof looking for those which demark a chapter.
- execute each bookmark in turn, so the script can make a note of the destination page each one points to, for example in an array.
- decide if the page counts between each chapter mean the chapter will end on a verso page.
- if not, use the doc (this).newPage() command to insert a blank page between the two chapters.
- repeat for each bookmark excluding the last one.
Snippet example to add a blank page between pages 13 and 14 (note the newPage command uses a 1-based numbering system, unlike other JSAPI commands):
var Rect = this.getPageBox("Crop");
var atPage = 13;
this.newPage(atPage, Rect, Rect);