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

Display partial UserID in Dynamic Stamp

bsauer
Registered: Nov 30 2010
Posts: 4

Hello,
 
I am trying to create a dynamic stamp with the initials of the person stamping along with the date in the format mm/dd.
 
I have successfully modified the code from a current dynamic stamp and have the result of: bs5555 11/30
 
I want the result to be: BS 11/30
 
I want to deploy this to multiple users so the initials will change. Below is my current code:
 
event.value = (new Date()).toString();
AFDate_FormatEx(" mm/dd");
event.value = (identity.corporation || (event.source.source || this).Collab.user)
+ event.value;
 
Thank you for any direction you can provide. I have very little experience with Java code! I am creating in Acrobat 9 Pro but want to deploy to users with Acrobat 8 Standard.
 
Brandyn

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You probably don't want the collaboration user parameter, this is usually the same the login name. Unless you know the exact format of the login names you'll never be able to reliably extract any info from it. Use the full user name instead, "identity.name". You're also better off using the regular date formatting function. Also, why is the corporation property in there? Do want the company name used instead of the user name?

Here's some code that uses a regular expression to extract all the first letters from the name parameter

event.value = identity.name.match(/^\w|\W\w/g).join("").replace(/\W/g,"").toUpperCase() + util.printd(" mm/dd",new Date());

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

bsauer
Registered: Nov 30 2010
Posts: 4
Thom,

Thank you for your quick response! Here is a little more info I probably should have provided the first time. Most users in our Organization do not complete the identity info inside of Acrobat. Each user is assigned a user id consisting of the first initial of first name, first initial of last name + 4 digit number. This is the main reason I was looking at going that route. I thought it would provide more consistent results. Sounds like you don't think that is true?

A developer friend of mine just sent me this code a few minutes after your response. I tried it out and it seems to work fine on my computer.

event.value = (new Date()).toString();
AFDate_FormatEx(" mm/dd");
var tempstring = (identity.corporation || (event.source.source || this).Collab.user);
tempstring = tempstring.slice(0, -4);
tempstring = tempstring.toUpperCase();
event.value = tempstring + event.value;

I am going to try moving the stamp over to my Acrobat 8 Standard machine and see what happens. Thank you again for the quick and easy to understand reply!

Brandyn
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Since there are some restrictions on accessing the 'identity' object, you will need to create a trusted function to access the 'identity' object's properties and place that code in an Acrobat application folder.

With a stamp you should be OK, since the stamps and their calculaitons are initialized when the Acrobat/Reader application initializes.

George Kaiser

bsauer
Registered: Nov 30 2010
Posts: 4
George,

Thank you for the response. I moved the file over to my Acrobat 8 Standard machine and it seems to work without issue. I have not done anything to create a trusted function. Can you expand on why I might have issues and provide me some info on how to setup what you describe?

Thanks,

Brandyn
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Our post crossed in processing.

Stamps are a special case for calculations. The usual calculations can not directly access the 'identity' object, but because dynamic stamps and any code within them is reviewed by the user or IT prior to adding the stamp, the dynamic stamps can access the 'identity' object. The dynamic stamps and their internal code are initialized with the initialization of Acrobat/Reader and do not need the special coding that other calculations require.

George Kaiser

bsauer
Registered: Nov 30 2010
Posts: 4
Thanks George! I did a lot of searching earlier today before posting and ran across one of your posts mentioning something similar.