Knowledge Base Article: KB355 - Created On: Jan 11, 2012 03:11 PM - Last Modified: May 2, 2012 06:23 AM
I want to use JavaScript to perform an action on a PDF but I can't find how to do that.
The JavaScript console is only accessible through the keyboard shortcut CTRL+J
There area number of actions that can be performed on a PDF document using JavaScript.
To do so simply
In the sample above the script reverses the page order by iterating through the document and changing the page numbers. The 'undefined' output is when the script comes to the end of the document. We could write JS code that would stop that happening but in this case it was not needed.
Examples
Iterate through a PDF and reverse the order of the pages.
for (i = this.numPages - 1; i >= 0; i--) this.movePage(i);
Check if a document contains bookmarks
function HasBookmarks(document)
{
return (document.bookmarkRoot.children != null) && (document.bookmarkRoot.children.length > 0);
}
HasBookmarks(this);it returns string "true" if there are bookmarks, and "false" otherwise.