Acrobat Javascript Samples Scripts

Introduction:

1. What is Acrobat JavaScript?
2. What can you do with Acrobat JavaScript?
3. Where can I read more about Acrobat JavaScript?
4. How to create a batch sequence with JavaScript code?
5. Sample Acrobat JavaScripts: Introduction

Sample Scripts:

Q & A
What is Acrobat JavaScript?
JavaScript is an object-oriented scripting language developed by Netscape Communications. Acrobat JavaScript implements extensions, in the form of new objects and their accompanying methods and properties, to the JavaScript programming language. These Acrobat-specific objects enable a developer to manipulate a PDF file, allowing the PDF file to communicate with a database, modify its appearance, and so on.
What can you do with Acrobat JavaScript?
Acrobat JavaScript enables you to perform calculations in form fields, respond to user actions, validate user data, modify appearance of Acrobat application, control the behavior of PDF documents, dynamically modify document's appearance and functions, process multiple PDF documents with batch sequences, dynamically create new pages based on template, interface to a database. Acrobat JavaScript code can be executed:
- as an action to respond to user input in the document.
- as document-level script to respond to actions like printing.
- as part of a batch processing sequence that can be applied to multiple files.
Where can I read more about Acrobat JavaScript?
Acrobat JavaScript enables you to do a wide variety of things within a PDF document. The Adobe Solutions Network (ASN) has an Adobe Acrobat JavaScript Training course that covers a wide variety of the possibilities available within Acrobat JavaScript.
Other Acrobat JavaScript documents available from Adobe: Acrobat JavaScript Scripting Guide - provides general introduction into JavaScript programming for Adobe Acrobat. Acrobat JavaScript Object Specification - contains detailed description of all Acrobat specific objects and classes.
How to create a batch sequence with JavaScript code?
1. Start Acrobat Professional.
2. Select “Advanced / Batch processing…” from the main menu.
3. Click “New Sequence” button.
4. Type in command name, for example “ExtractEmails” and click”OK”.
5. Click “Select Commands” button in “Batch – Edit Sequence" dialog.
6. Select “Execute JavaScript” item from the list and click “Add>>” button.
7. Now click “Edit…” button and “JavaScript Editor” dialog will pop up.
8. Copy JavaScript code into this dialog and click “OK”.
9. Click “OK” three times until you are back to “Batch Sequence” dialog
10. Now you just created new batch command that will be always available for batch processing.
11. Optional step: click "Output Options" button and define output file name and some additional options. Desired options may vary depending on script requirements.
12. To run the command: select it from the list of commands and click “Run Sequence” button.
Sample Acrobat JavaScripts

Most sample scripts provided on this page are designed to be run as batch sequences. Most scripts have comments in the code that will help you to understand the logic and make any custom modifications. EverMap LLC. provides these scripts for reference only, without warranty of any kind (see disclaimer below). No technical support is provided.
DISCLAIMER: All javascripts on this web site are provided "as is" without warranty of any kind either express or implied, including but not limited to the implied warranty of merchantability and fitness for a particular purpose. The entire risk arising out of the use or performance of these scripts and documentation remains with you.

Mark misspelled words with squiggle
Description: Spellchecks every word in the document and marks misspelled ones with squiggle annotation.
Submitted by: Unknown / from Acrobat JS Guide
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: MarkMisspelledWords.txt
Create page bookmarks
Description: Automatically creates a bookmark for each page in the document
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: CreatePageBookmarks.txt
Duplicate every page in the document (carbon copy)
Description: Every page will be repeated N-times in the output (1,1,1,2,2,2...)
Date: 14 Nov 2004
Acrobat Versions: 5.0 and up
Code: CarbonCopyPages.txt
Extract email addresses
Description: Extracts all email addresses from the document into new pdf file
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: ExtractEmails.txt
Extract ISBN numbers
Description: Extracts all ISBN numbers from the document into new pdf file
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: ExtractISBN.txt
Extract Social Security Numbers
Description: Extracts all SSN numbers from the document into new pdf file
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: ExtractSSNs.txt
Extract URL addresses
Description: Extracts URL addresses (http,https,ftp,www...) from the document into new pdf file
Date: 11 Nov 2004
Acrobat Versions: 5.0 and up
Code: ExtractURLs.txt
Rotate Pages In The Document
Description: Rotate all or some pages in the document.
Date: 10 Jan 2005
Acrobat Versions: 5.0 and up
Code: RotatePages.txt
Rotate Only Landscape/Portrait Pages
Description: Rotate only landscape or portrait pages in the document.
Date: 10 Jan 2005
Acrobat Versions: 5.0 and up
Code: RotatePagesLandscape.txt
Delete Pages Without Text
Description: Delete pages from the document that contain no text elements.
Date: 19 Jan 2005
Acrobat Versions: 5.0 and up
Code: DeletePagesWithoutText.txt
Add Navigation Buttons To All Pages
Description: Add "Previous Page", "First Page" and "Next Page" and "Go Back To Previous View" navigation buttons to the top of every page in the document. Contain simple function for creating a button, illustrates how to set button attributes, size, action and tooltip. Customize this script to create desired button appearance and behavior.
Date: 17 July 2008
Acrobat Versions: 5.0 and up
Code: AddNavigationButtons.txt
Renaming Files Using Bookmark Text
Description: Use this script as an example how to use bookmark titles and rename files. This script takes first 3 bookmarks and creates a custom filename that is used to save a file.
Date: 27 July 2009
Acrobat Versions: 5.0 and up
Code: RenameUsingBookmarks.txt
Saving Files With Time Stamp In The Filename
Description: this script creates unique names for documents based on a current time. This script does not overwrite existing files.
Date: 28 July 2009
Acrobat Versions: 5.0 and up
Code: SaveFilesWithTimeStamp.txt
Create Report Document Listing All Bookmarks
Description: this script creates a report document (PDF) that lists all bookmarks in the input file.
Date: 28 July 2009
Acrobat Versions: 5.0 and up
Code: BookmarkReport.txt