Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript for Search and Redact Action

Community Beginner ,
Jul 20, 2023 Jul 20, 2023

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

TOPICS
JavaScript , PDF
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jul 20, 2023 Jul 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2023 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2023 Jul 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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 20, 2023 Jul 20, 2023

TRY 67?! What have you done with Thom! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 20, 2023 Jul 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2023 Jul 20, 2023

This is a public forum. If you want to send Thom Parker a private message do so via the PM system.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2023 Jul 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

 

Yes, but that can't be automated. You will have to do it manually.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2023 Jul 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 20, 2023 Jul 20, 2023
LATEST

Thanks Thom! You are the Best!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines