Skip to main content
Participant
July 20, 2023
Answered

Javascript for Search and Redact Action

  • July 20, 2023
  • 2 replies
  • 1763 views

Hi Thom, Its me again!

I am using the action wizard and the built in Search and Remove Text action to mark certain phrases for redaction, moving to that page in javascript and adding a bookmark there. Unfortunatley I have to use variable names in the Search and Remove Text action that I read from a different file. I was wondering if there were a way to either add a variable to the Search and Remove Text action, or use the search and remove text action through Javascript, where I could use a variable?

Any help would be very appreciated

This topic has been closed for replies.
Correct answer Thom Parker

As pointed out by Try67, the Redact Search parameters cannot be accessed from JavaScript. But the Redact Search does have an option for loading a list of search strings from a file. You could create a separate script for creating this file. So it'd be a two step process.

1. Run the tool to create the search list

2. Run the Redact Search, manually loading the search list.

 

   

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
July 20, 2023

As pointed out by Try67, the Redact Search parameters cannot be accessed from JavaScript. But the Redact Search does have an option for loading a list of search strings from a file. You could create a separate script for creating this file. So it'd be a two step process.

1. Run the tool to create the search list

2. Run the Redact Search, manually loading the search list.

 

   

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
July 20, 2023

Thanks Thom! You are the Best!

try67
Community Expert
Community Expert
July 20, 2023

> I was wondering if there were a way to either add a variable to the Search and Remove Text action

- No.

 

> or use the search and remove text action through Javascript, where I could use a variable?

- Yes, but doing it like that is much less efficient and much more complicated. It will not likely work with very large files.

try67
Community Expert
Community Expert
July 20, 2023

To clarify the second point, you can't actually call the Search & Remove Text command using JS, but you can mimic what it does using a script. The code for it will have to be written in full, though, and it's not a trivial task (especially not if the search terms are more than one word).

Participant
July 20, 2023

Do you think I could do it by reading the variables to a text file and importing the text file in the Search and DESTROY action