Copy link to clipboard
Copied
I am trying to create a custom dynamic stamp in which the user is prompter to enter information when the stamp is placed.
Here is the code I am using:
var cAsk = "Please enter Inspection Date";
var cTitle = "Inspection Date";
if(event.source.forReal &&
(event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))
{
var cMsg = app.response(cAsk, cTitle);
cMsg += util.printd("mm/dd/yyyy", new Date());
event.value = cMsg;
event.source.source.info.DocumentState = cMsg;
}
However I keep getting the error: event.source is null.
Help!!
Copy link to clipboard
Copied
Change this:
if (event.source.forReal && (event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))
To:
if (event.source && event.source.forReal && (event.source.stampName == "#-65c2ZoyHu7QwjOp-fjeqA"))
Copy link to clipboard
Copied
Your script should work. However, you will always get the error "event.source is null" in the console after you add or change the script because the script runs when you close the field properties box and event.source will be null until you apply the stamp. Also, do the end users all have Acrobat Pro or Standard? Your script won't work with Reader because you can't write custom metadata.
Copy link to clipboard
Copied
All the end users have Acrobat Standard, so it should work right? The people viewing the PDFs with the stamp might only have Reader but that should not make a difference, correct?
Copy link to clipboard
Copied
Yes, that's correct, but I would recommend simply removing that line altogether. Someone added it to some sample code a long time ago and people keep copying and using it, even though it's not necessary at all and just complicates things.
Copy link to clipboard
Copied
Which line are you referring to? The first if statement? Or just the condition event.source.forReal?
Copy link to clipboard
Copied
I was referring to this line:
event.source.source.info.DocumentState = cMsg;
You should keep the event.source.forReal part.
Copy link to clipboard
Copied
Yes and yes.