How to Batch Replace Custom PDF Stamps with an Acrobat Script
Question details
The user needs a method to batch replace the appearance of custom stamps across thousands of PDF files using an Acrobat JavaScript while preserving the original size and location.

- Product
- Adobe Acrobat Pro
- Device & OS
- not provided
- Scenario
- Updating outdated or incorrect stamp graphics (e.g., changing 'Approved' to 'Not Approved') on a large volume of PDF documents simultaneously.
- Observed behavior
- The user needs to programmatically scan for existing stamp annotations and modify their AP (appearance) property without altering their physical placement on the pages.
Ensure you have Adobe Acrobat Pro installed, as standard versions do not support the Action Wizard required for batch processing scripts. Always create a secure backup of your PDF files before running bulk JavaScript operations.
Use JavaScript and the Action Wizard in Acrobat Pro
Execute a custom JavaScript using Acrobat Pro's Action Wizard to identify and replace the specific stamp appearance (AP property) across multiple files.
Acrobat JavaScript allows you to manipulate PDF annotations programmatically. By iterating through a document's annotations and locating the specific AP (appearance) property, you can replace the stamp graphic while keeping its original dimensions and coordinates untouched.
Place the target stamp on a blank PDF page. Select the stamp with your cursor, open the JavaScript console (Ctrl+J on Windows or Cmd+J on Mac), type 'this.selectedAnnots[0].AP', and press Enter to retrieve its exact AP value.
Write a script utilizing the 'syncAnnotScan()' function to scan all annotations in the document. Create a loop that checks if an annotation's AP matches the old stamp (e.g., 'SBApproved') and replaces it with the new stamp's AP value (e.g., 'SBNotApproved').
Open Adobe Acrobat Pro, navigate to 'Tools' > 'Action Wizard', and click 'New Action'. Under 'More Tools', add the 'Execute JavaScript' tool to your action steps and paste your completed replacement script into the prompt.
In the Action workflow, click 'Add Folder' to select the directory containing your thousands of PDFs. Click 'Start' to process the files and automatically update all custom stamps.

Manage PDFs and Documents with WPS Office
While running complex Acrobat JavaScripts requires an expensive Adobe subscription, WPS Office provides a lightweight, highly compatible, and free alternative for your daily PDF editing, stamping, and document management needs.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
- 2. Access the Stamp Tool: Navigate to the 'Comment' tab on the top ribbon and click on the 'Stamp' button.
- 3. Apply Custom Stamps: Choose from a variety of pre-made stamps or click 'Custom Stamp' to upload your own design and apply it directly to the page.

Frequently Asked Questions
Can I run this batch JavaScript in Adobe Acrobat Reader?
No. The Action Wizard and advanced batch JavaScript execution are exclusive features of Adobe Acrobat Pro. Acrobat Reader users can only execute basic, document-level scripts and cannot process multiple files in batch.
How do I find the exact AP (Appearance) value of a newly created stamp?
You can find any stamp's AP value by placing the desired stamp on a blank PDF page, selecting it, opening the JavaScript debugger console (Ctrl+J or Cmd+J), and running the code 'this.selectedAnnots[0].AP'.
Will the replacement script change the size or location of my custom stamps?
No. By exclusively modifying the AP property of the stamp annotation, the Acrobat script preserves the original bounding box, dimensions, and exact page coordinates of the original stamp.




