Skip to main content
Participant
December 3, 2021
Question

Developing a Javascript code in action wizard to find a specific text and act accordingly (Pro DC)

  • December 3, 2021
  • 2 replies
  • 664 views

Hello everyone,

I am trying to execute a Javascript code in action wizard but it is not working and I dont have much experience in writing codes. Basically what I need to do is to batch process many documents and watermark them according to the text found in the documents. 

So Im looking for a 3 phrases (word should match and in order) and when the phrase is found, the document has to be watermarked with a specific image and text - like a stamp. I am not sure if dynamic stamping would work here!

Your help is highly appreciated and please let me know if you need further clarification.

Thanks  

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 5, 2021

How large are the files? How long are the search terms?

Participant
December 5, 2021

Thank you for your response.

 

The batch files that I am executing in action wizard are around 120 files (each file is a 1 page document only). These are the sentences that im looking for in each document:

 

Expect FIRST vaccine dose

Expect SECOND vaccine dose

course complete

 

ls_rbls
Community Expert
Community Expert
December 5, 2021

If would be helpful to look at the script that you're currently using.

Participant
December 5, 2021

Thank you for your response. Im using this script:

 

if (search.query("Expect FIRST vaccine dose", "ActiveDoc")) {
this.addWatermarkFromFile({
cDIPath: "/C/users/enimed/desktop/stamps/Moderna.jpg",
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.top,
nHorizValue: -72, nVertValue: -144,
nScale:0.5,
nRotation: 0
});
} else if(search.query("Expect SECOND vaccine dose", "ActiveDoc")) {
this.addWatermarkFromFile({
cDIPath: "/C/users/enimed/desktop/stamps/Pfizer.jpg",
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.top,
nHorizValue: -72, nVertValue: -144,
nScale:0.5,
nRotation: 0
});
} else if(search.query("course complete", "ActiveDoc")) {
this.addWatermarkFromFile({
cDIPath: "/C/users/enimed/desktop/stamps/Booster.jpg",
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.top,
nHorizValue: -72, nVertValue: -144,
nScale:0.5,
nRotation: 0
});
}

try67
Community Expert
Community Expert
December 5, 2021

That won't work, because the query method has no return value. You'll need to search the field yourself, using the getPageNthWord method. Note that it only returns one word at a time, so you'll have to split your search term into individual words, or collect the entire page's contents into a single string, then search it.

I'm also not sure that calling addWatermarkFromFile multiple times is going to work. I think the watarmarks you add will overwrite one another...