Skip to main content
Participant
January 31, 2020
Question

Custom Dynamic stamp to every page automatically

  • January 31, 2020
  • 2 replies
  • 1230 views

Hello:

 

I am very new to this community but after some research I created a Dynamic Stamp that requests user input and then stamps a case number on my 100 plus page documents.  Right now I have to stamp every page on the document.  I would like the stamp to apply to every page automatically after the user inputs the information.  This is the simple code I am using for my dynamic stamp.  I placed it in the custom calculations porperties of a form text field.  

 

if ((event.source.forReal)&&(event.source.stampName == "#ClearStamp"))
{
this.getField("Case Number").value = app.response("Enter Case Number");

}

 

That works great so I found this additional script from another post: 

 

/* Multiple Page Stamp */

this.syncAnnotScan();
var annt=this.getAnnots(this.pageNum)[0];
var props=annt.getProps();

for(var i=0;i<this.numPages;i++){

props.page=i;

if(i!=this.pageNum)

this.addAnnot(props);

}

 

So I combined this script all together:

 

if ((event.source.forReal)&&(event.source.stampName == "#ClearStamp"))
{
this.getField("Case Number").value = app.response("Enter Case Number");

}

this.syncAnnotScan();
var annt=this.getAnnots(this.pageNum)[0];
var props=annt.getProps();

for(var i=0;i<this.numPages;i++){

props.page=i;

if(i!=this.pageNum)

this.addAnnot(props);

}

 

I have very little scripting knowledge (Close to zero) so any help I can get would be great.   

 

Thanks!!

 

 

 

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
January 31, 2020

Try67 is Right, you can only duplicate a stamp from a script outside the stamp, and only after the stamp is applied.

Here is a very simple script that copies the "selected" stamp to every page of the PDF. Run it from the console window.

 

var props = this.selectedAnnots[0].getProps();
var nCurrent = props.page;
for(var i=0;i<this.numPages;i++)
{
     props.page = i;
     if(i!=nCurrent)      this.addAnnot(props);
}



 

You'll find a tutorial on the Console window here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
January 31, 2020

You can't do that because when the script executes the stamp doesn't yet exist. You need to use another script, executed after the stamp has been applied, that duplicates it to the other pages.