PDF Editing Issues

How to Redact the Same Area in Multiple PDFs with JavaScript

Huma Ashraf ChHuma Ashraf Ch Nov 3, 2026 869 views

Question details

The user wants to automate the process of redacting a specific, identical area across multiple PDF files located in a folder using JavaScript.

How to Redact the Same Area in Multiple PDFs with JavaScript
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
Managing multiple PDF files in a batch where the same region (such as a header, footer, or specific form field) needs to be redacted for security or privacy compliance.
Observed behavior
Applying redactions manually across many files is highly time-consuming, prompting the need for a programmatic JavaScript-based action to automatically apply and permanently execute redaction annotations.
Before you start

Ensure you have Adobe Acrobat Pro installed, as standard versions do not support the Action Wizard required for executing batch JavaScript. Always create a backup of your target folder before running automated redaction scripts to prevent irreversible data loss.

Solution 1Recommended

Automate Redactions using Acrobat Pro Action Wizard and JavaScript

Use Adobe Acrobat Pro's Action Wizard to run a custom JavaScript that dynamically adds and applies redaction annotations to all PDFs in a selected folder.

This workflow relies on the Acrobat JavaScript API, specifically utilizing the addAnnot method to define the redaction coordinates and the applyRedactions method to permanently strip the underlying content. You must calculate the exact PDF page coordinates (in points) for the area you wish to redact before writing the script.

1
Open the Action Wizard

Launch Adobe Acrobat Pro. Navigate to the 'Tools' tab and select 'Action Wizard'. Click on 'New Action' in the top toolbar to start configuring your batch process.

2
Select the target folder

Under the 'Files to be Processed' section on the left, click 'Add Folder' and browse to the directory containing all the PDF files you want to redact.

3
Add the JavaScript execution step

Under 'Choose tools to add', expand the 'More Tools' panel and select 'Execute JavaScript'. Click the '+' icon in the center to add it to your Action steps on the right.

4
Input the redaction script

Click 'Specify Settings' on the newly added Execute JavaScript step. Input your script using this syntax: var annot = this.addAnnot({type: 'Redact', page: 0, quads: [[x1, y1, x2, y2]]}); followed by this.applyRedactions();. Replace the quad coordinates with your specific target area.

5
Save and execute the Action

Uncheck the 'Prompt user' checkbox so the script runs automatically for each file. Click 'Save', name your action 'Batch Redact', and then click 'Start' to process the entire folder.

Automate Redactions using Acrobat Pro Action Wizard and JavaScript
Coordinate System Precision: PDF page coordinates are measured in points starting from the bottom-left corner of the page (0,0). Test your script on a single file copy first to verify the redaction area perfectly aligns with the target text.
Secure and Easy PDF Editing

Redact Sensitive Information Easily with WPS PDF

While scripting batch processes requires advanced programming knowledge, WPS PDF provides a highly intuitive and reliable Redact tool. It allows you to quickly and permanently remove sensitive text, images, and data from your PDF documents without writing any code.

  1. 1. Open the PDF in WPS Office: Launch WPS Office on your device and open the PDF document that contains the sensitive information you need to hide.
  2. 2. Navigate to the Redact tool: Click on the 'Protect' tab located in the top ribbon menu, then select the 'Redact' feature.
  3. 3. Mark areas for redaction: Click and drag your cursor over the specific text, images, or custom areas you wish to conceal. A visible outline will indicate the selected region.
  4. 4. Apply the redactions: Click 'Apply Redactions' in the redaction toolbar. A warning will appear confirming that the underlying information will be permanently removed. Click 'OK' to finalize the process and save your secure document.
Permanently black out sensitive text, images, and metadataHighly compatible with all standard PDF formats generated by AdobeUser-friendly interface requiring no JavaScript or programming skillsComprehensive suite of PDF editing, merging, and conversion tools
microsoft office alternative - wps office

Frequently Asked Questions

Can I batch redact PDFs using Adobe Acrobat Standard?

No, Adobe Acrobat Standard does not include the Action Wizard tool. The Action Wizard is required to run automated batch JavaScript processes on multiple files in a folder, so you must use Acrobat Pro.

How do I find the correct coordinates for the addAnnot method?

PDF coordinates are measured in points (72 points per inch) starting from the bottom-left corner (0,0) of the document. You can use Acrobat's 'Measure' tool, the Preflight tool, or a cursor coordinate plugin to determine the exact 'quads' required for your redaction box.

Are redactions applied with JavaScript permanent?

Yes, provided the script includes the applyRedactions() method immediately after addAnnot. Without this method, the redaction is only placed as a draft annotation, meaning the visual black box is present but the underlying text data has not yet been removed from the file.

Why did my batch redaction script leave the text searchable?

If you added a standard black rectangle annotation instead of a true redaction annotation (using type: 'Redact' in your addAnnot parameters), the text underneath remains entirely intact and searchable. Always ensure you are invoking the specific redaction API methods.