Skip to main content
rakeshk21205956
Inspiring
November 22, 2019
Question

PDF Form Script to search pages for a word then list all page no. which doesnot contain that word.

  • November 22, 2019
  • 6 replies
  • 1442 views

Want a script to do the following
- Search all pages in a PDF document -
-  Every page should have a certain word or phrase based on user prompt in the Adobe Actions
-   If a page does not have this word or phrase, then print a list of pages that does not have this word or phrase. - want script to this step.
-  this code will be used from Adobe Action Wizard -

 

I have got script to search and mark the word or phrase only want help for doing the last thing, i.e to show the list of pages which doesnot contain the word/phrase searched for.

 

 

 

//HIGHLIGHTING COLOR

var colHilite = color.yellow;
var oDoc = event.target;

var aAnnts = oDoc.getAnnots({sortBy:"Author"});
for(var i=0;i<aAnnts.length;i++)
{
if(aAnnts[i].type == "Redact")
{
aAnnts[i].type = "Highlight";
aAnnts[i].strokeColor = colHilite;
}
}

This topic has been closed for replies.

6 replies

JR Boulay
Community Expert
Community Expert
November 22, 2019

See my free abracadabraTools plugin : https://www.abracadabrapdf.net/utilitaires/utilities-in-english/abracadabratools_en/

And its "Deletes all pages without comments" function.

 

I just have to change a "!=" into a "==" in the script to made it "Delete all pages with at least one comment"

Should it be ok for you ?

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
November 22, 2019

Do you want the words to be highlighted?

So it looks like you have a 2 step process.

1) run a redaction search.

2) run a script to figure out which pages don't have the searched words.

 

Did you do this as an Action?  This is the best way to do it.

So the script for #2 is tricky. 

One way to do this is to use the annotation list to create a sorted list of  page numbers onwhich the annots appear.

Then walk this list to create a list of numbers that do not appear in the first list.

 

Do you have any programming experience?

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
November 22, 2019

You can check every page with the parameter nPage of the method getAnnots.

try67
Community Expert
Community Expert
November 22, 2019

This code has nothing to do with what you described.

Inspiring
November 22, 2019

I whould doblbe check your script. It appears to be serching the annotations within a PDF that are of the type "Redact" or redaction annotations and will be removed when Redaction is applied. This is not the same as searching for a word or string within the text of the PDF.

Legend
November 22, 2019

Did you get my reply about the method you will need to use at the heart of the code you write, to get each word in turn?