Copy link to clipboard
Copied
Hi, I was wondering whether it was at all possible, from the Action feature or using some JavaScript, to automatically change the color of level-1 bookmarks in multiple PDFs (nor created from Word), and also to delete the first 2 bookmarks multiple PDFs.
Any idea will be welcome.
Thank you.
Copy link to clipboard
Copied
Is that change the formatting in your document itslef or in the bookmark panel on the side of the screen?
Within a document, the bokmarks do not really have a hierarchy, only on the side panel. As far as i remember, the side panel keep the text for the bookmark with basic formatting options. more at Page thumbnails and bookmarks in PDFs, Adobe Acrobat (scroll half-way down the page) to 'Change the text appearance of a bookmark'.
You can also check this Developing Acrobat Applications Using JavaScript (adobe.com) (page 126-127).
Also, to automate the deletion, do the 2 bookmarks have the same name in each document? what do they have in common?
Copy link to clipboard
Copied
Thank you, Eric. What I am referring to is the bookmarks on the side panel, which have 2 levels in my case, reflecting the heading levels within the document. I want only the level 1s to have a different color.
And concerning the bookmarks to be delete in the side panel, they are just the first ones there. The names will differ in the different PDFs (translations) but they will always be positioned as first and second in the bookmark side panel. They should remain within the document be disappear in the bookmark side panel.
Copy link to clipboard
Copied
You can do is using this script (I used blue, since you didn't specify what color you wanted):
this.bookmarkRoot.children[0].remove();
this.bookmarkRoot.children[0].remove();
for (var i=0; i<this.bookmarkRoot.children.length; i++) {
this.bookmarkRoot.children[i].color = color.blue;
}
Copy link to clipboard
Copied
Thank you very much! How do I execute this, please?
Copy link to clipboard
Copied
From the JS Console, a button, an Action or a Custom Command, among others.
Copy link to clipboard
Copied
Sorry, I ran it from here but it did not change anything in the selected PDFs:
Copy link to clipboard
Copied
Did you add a Save command, too?
Copy link to clipboard
Copied
Also, I think you used the code as the Action's description. It should be used under an Execute JavaScript command (make sure to untick the "Prompt User" check-box), followed by the Save command, like this:
Copy link to clipboard
Copied
Wonderful! It is working fine now.
How can I change the blue color to R=0, G=75, B=151 and specify that the font face should be bold, please?
Copy link to clipboard
Copied
Use this
this.bookmarkRoot.children[i].color = ["RGB", 0/255, 75/255, 151/255];
this.bookmarkRoot.children[i].style = 2; // bold
Copy link to clipboard
Copied
Excellent! It will save me a lot of time.
Many thanks, try67.
Copy link to clipboard
Copied
Sorry to come back to you with this. I tried to enter the 2 lines of code but I receive a syntax error. Can you help, please?
Copy link to clipboard
Copied
This code was written for Acrobat, not for a web-page.
Copy link to clipboard
Copied
Sorry, didn't realize this is from an Action file... Disregard the above comment.
Copy link to clipboard
Copied
Does you change the sequence file?
Copy link to clipboard
Copied
Sorry, what do you mean?
Copy link to clipboard
Copied
Where does you enter the 2 lines of code?
Copy link to clipboard
Copied
Well, exactly as shown in my screenshot.
Copy link to clipboard
Copied
What syntax error message are you getting? Why are you editing the SEQU file directly, instead of doing it via the Action Wizard in Acrobat?
Copy link to clipboard
Copied
OK, I am now trying in the Action Wiz
ard, and here's what I first get:
Copy link to clipboard
Copied
The file has been corrupted. You should not be seeing any of those XML tags in the JS editor.
Delete it and create a new one. Do NOT edit this file directly, only use the editing tools within Acrobat.
Copy link to clipboard
Copied
It IS WORKING now! Thank you.
Additional questions, if I may:
- Would it be possible to have Acrobat save all processed files automatically without first asking?
- Would it be possible to have the same Acrobat action also add some text automatically to the Author and Subject fields of the processed PDFs before saving?
Copy link to clipboard
Copied
Have you added the save step?
Copy link to clipboard
Copied
See: