Copy link to clipboard
Copied
Hi i need help on how to run a java script that puts a stamp/text on the first page of every bookmark. does anyone know how to do this?
Copy link to clipboard
Copied
If the bookmarks tree only has one level you can easily traverse it from the root, executing each bookmark (using the exec method of the Bookmark object) and then adding the stamp to the current page.
If the tree has branches, though, you would need to write a recursive function to traverse the entire tree.
You add a stamp using the addAnnot method of the Document object.
Copy link to clipboard
Copied
can you please show me how that code would look? I don't really know how to do that. Thanks
Copy link to clipboard
Copied
(The bookmark tree only has one level)
Copy link to clipboard
Copied
This is not a simple task, even with a single level of bookmarks. I've provided the basic approach to doing it, but if you're interested in having someone write the entire code for you contact me privately (try6767 at gmail.com) and we could discuss it in detail, including the price.
Copy link to clipboard
Copied
How good are you with JavaScript?
Copy link to clipboard
Copied
i don't know anything bout java script. Just know that its possible to do
Copy link to clipboard
Copied
Well, then you will either need to lean JavaScript or hire someone.
But here is a basic outline for a solution.
A. Loop over the bookmarks.
B. Inside the loop
1. set the page number to the first page,
2. execute bookmark
a. If page number changes, then continue
b. If page number does not change, then set to last page and execute bookmark again
c. If page number changes, then continue
d. If page does not change, then the bookmark either doesn't have a destination, or it does something else. Move on to next bookmark.
3. Add stamp to predefined location on current page.
Those are the things you need to learn how to do. You'll fine lots of info on this topic here
And here:
https://acrobatusers.com/tutorials/finding-page-boundaries
https://acrobatusers.com/tutorials/auto_placement_annotations