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

Dynamic Stamp returning null for event.source

Community Beginner ,
Jul 02, 2018 Jul 02, 2018

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!!

TOPICS
Acrobat SDK and JavaScript

Views

2.9K

Translate

Translate

Report

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 02, 2018 Jul 02, 2018

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"))

Votes

Translate

Translate

Report

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
Participant ,
Jul 02, 2018 Jul 02, 2018

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.

Votes

Translate

Translate

Report

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 03, 2018 Jul 03, 2018

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?

Votes

Translate

Translate

Report

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 03, 2018 Jul 03, 2018

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.

Votes

Translate

Translate

Report

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 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Which line are you referring to? The first if statement? Or just the condition event.source.forReal?

Votes

Translate

Translate

Report

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 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

LATEST

I was referring to this line:

event.source.source.info.DocumentState = cMsg;

You should keep the event.source.forReal part.

Votes

Translate

Translate

Report

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
Participant ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Yes and yes.

Votes

Translate

Translate

Report

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