These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Script doesn't work

RickW363
Registered: Nov 28 2011
Posts: 3

I have no idea what I'm doing but I'm told this should work but doesn't.
 
I am using Acrobat X on a Windows 7 pro machine and I'm trying to create a custom stamp that works exactly like one of the stock dynamic stamps. I created a stamp, saved it as a PDF then added a text field. As the definition for the text field, I cut and pasted the "calculated data" definition from a stock stamp. It's supposed to grab the log-in name from the computer and add the time and date. All I get is the time and date - the name doesn't appear. The stock stamp works perfectly. Any clue what I'm doing wrong? The script from the stock stamp is as follows:
  
event.value = (new Date()).toString();
AFDate_FormatEx("h:MM tt, mmm dd, yyyy");
event.value = "By " + ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name)
+ " at " + event.value);

My Product Information:
Acrobat Pro 10.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Have you confirmed that the time and date getting set correctly when you apply the stamp?
RickW363
Registered: Nov 28 2011
Posts: 3
Yes, that part works fine. Also of note: The 2nd event.value statement is supposed to print the words "by" and "at". It doesn't do that either.
RickW363
Registered: Nov 28 2011
Posts: 3
Yes, that part works fine. Also of note: The 2nd event.value statement is supposed to print the words "by" and "at". It doesn't do that either.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Are any errors shown in the JavaScript console (Ctrl+J)?
Hoyane
Registered: Nov 26 2011
Posts: 33
The reason it's not working is you did not set the page template.
Go to to TOOLS/DOCUMENT PROCESSING/PAGE TEMPLATES and add this

#DReviewed=Reviewed

Reviewed being the name of the text field. you can change it to whatever you want as long as the text field is same name.
#Dpage=page
Then the field you want the info to go to should be named "page" also.

should work after that.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Hoyane wrote:
The reason it's not working is you did not set the page template.
Go to to TOOLS/DOCUMENT PROCESSING/PAGE TEMPLATES and add this

#DReviewed=Reviewed

Reviewed being the name of the text field. you can change it to whatever you want as long as the text field is same name.
#Dpage=page
Then the field you want the info to go to should be named "page" also.

should work after that.
In case someone comes across this, it is not correct. The template name has nothing to do with any of the form field names that are present on the template page.

The value of a form field in a dynamic stamp is set using the calculate event of a field. The # at the beginning of the template name is needed for dynamic stamps.

Hoyane
Registered: Nov 26 2011
Posts: 33
My apologies. I am not good at doing this stuff. I just know that's how i got it to work. Never bothered testing if it would work with different names. I seen it said Reviewed and the field name was Reviewed so i thought that's how it was supposed to be.
So does that mean it only needed the #DWHATEVER to make it function like a stamp? Does not even need the =Reviewed or to match any field name. Does the D right after the # mean anything?
Learn a little more each day!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
The initial # in the template name is needed for dynamic stamps, but not for static stamps.

The two names separated by the = character are the internal and external stamps names (for lack of remembering the correct terms). The name after the = character is what (pre-10) gets displayed in the stamp list. I consider it a bug that they chose not to display it in Acrobat/Reader 10.

The D after the # is just a naming convention that Adobe uses as an indication that the stamp is dynamic. It is not required.
ultimate_ed
Registered: Dec 5 2011
Posts: 3
So, is there a solution to this problem? I'm running into the exact same issue as the OP. Various dynamic stamp tutorials, including ones here, indicate to do what the OP described - copy the box from one of the built in dynamic stamps and paste it into the new stamp to get the name and date.

I get the same issue where, when I paste it into the new stamp, it initially shows correctly. However, if I do anything to it, even so much as trying to resize the field, it kills of the user ID portion.

The script itself in the "Custom Calculation Script" box looks like this from the built in dynamic stamp:


event.value = (new Date()).toString();
AFDate_FormatEx("h:MM tt, mmm dd, yyyy");
event.value = "By " + ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name)
+ " at " + event.value;


I've also noticed that, if I edit the original dynamic stamp (as I did to copy the code for the past above, and hit OK - the original stamp changes to only show the date as well. I have to his cancel to keep it from messing up the stamp.

It seems to ignore everything after the first semicolon.

I tried copying and pasting and then editing as I didn't want the time, just the date in my own stamp. That part works - when I edit, I get just the date and not the time. However, the exercise remains moot if the persons name won't show up on the stamp.
Hoyane
Registered: Nov 26 2011
Posts: 33
Just copy/pasting the calc script is not enough. You have to add a page template. I got the same results until this was done. Under Document Processing> Page Templates just add #. This sign is needed for acrobat to look at it as a dynamic stamp and treat it as such. The script will not work with out it.Additionally if you import the new stamp using "Create Custom Stamp" it will lose its Calc. Code. You have to place your stamp in the stamp directory. C:\Users\Hoyane\AppData\Roaming\Adobe\Acrobat\10.0\Stamps Here it will automatically detect your stamp.


ultimate_ed
Registered: Dec 5 2011
Posts: 3
I checked, it's already got the # in the template name.

I'm using Acrobat 9, if it matters at this point. From what I've read in these forums and other places, it doesn't sound like stamp creation has changed all that much in that last few versions.

It's frustrating as I'm seeing this same situation posted in different adobe forums and sites, and no one seems to have a satisfactory answer as to why it's happening or how to fix it.

I have followed this tutorial

http://acrobatusers.com/tutorials/2007/02/custom_dynamic_stamp

But it just doesn't work. As soon as I try to edit the properties of the text box and make any change - orientation, calc code (to change the date format), anything - the user name disappears!
ultimate_ed
Registered: Dec 5 2011
Posts: 3
Alright, I think I may have figured a few things out. The behavior is still strange, but I'm at least getting the results I need.

With the built in dynamic stamps, when you open the for edit you see "By foozle at [some time and date]"

When I try to make a new stamp using copying that block over, it only shows the time and date. However, when I save the file and actually apply the stamp to a document, it does print the full text like the built in dynamic stamps.

It's still odd, as it makes it difficult to format the box since what I see in the final stamp is not what I see when I edit the stamp - automatic font sizing makes the final text much smaller once it puts in the username.

In conclusion, I'm functional enough. Probably wouldn't hurt to update that tutorial with a warning about this weirdness.

Thanks to all on this site for your help.
Hoyane
Registered: Nov 26 2011
Posts: 33
As near as i can tell the reason/method as to why it doesn't/does show the full text when opening is as follows.
In tests i've done I started with the file in a work folder on my desktop.
At this point it does not display full text Ex: 9:38 pm, Dec 08, 2011
If you move the file to the C:\Users\Hoyane\AppData\Roaming\Adobe\Acrobat\10.0\Stamps and open it from there it shows By Hoyane at 10:14 pm, Dec 08, 2011
If you close it and move it out of the stamps folder it will cease to display full text.
However if you make a change to the file while still in the stamp folder and try to save it will say access restricted, choose to save it to the desktop.
Open it and it will always display full text but it will be locked to the day/time/name it was saved. The update feature of the stamp upon opening appears to only work while in the stamps folder.
So if you ever wanted the name and date/time you see when opening the stamp file outside of the stamps folder you would have to perform the steps above.

Additionally if you want the text bigger use replace image to insert a bigger page then go edit and extend the length/width of the field.

Hope the info was useful.