Page 1 of 1

Add an identity and time to a dynamic stamp

Posted: Sat Jan 12, 2019 5:01 pm
by LFlat
Hey there!

I´ d like to know how to add an identity to a dynamic stamp using javascript or another trick.
I've already tried using the following script, but it needs to be able to use the windows user and not the creators PDF-XChange Editor identity.

if((identity.name != null) && !/^\s*$/.test(identity.name))
event.value = identity.name;
else
event.value = identity.loginName.replace(/\./g," ").replace(/\./g," ").replace(/\b(\w)/g,function(Word,cFst){return cFst.toUpperCase()});

Also, I want to insert the time and date as the dynamic stamp is being used as well. I´ ve already tried the following javascript for creating a dynamic stamp which uses the current time and date as it´ s being used.

var d = new Date;
event.value = util.printd("dd.mm.yyyy HH:MM", d);

Thanks in advance!

LFlat

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 10:02 am
by Tracker Supp-Stefan
Hello LFlat,

Can you please check and make sure that you are using the latest build of our products?
As with it - your script does seem to work fine and capture both values correctly:
with_name_specified.png
without_name_specified.png
Cheers,
Stefan

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 9:27 pm
by LFlat
Thanks for the reply, I am already using the latest build and the script posted above seemed to work just fine with me as well.
My problem is that the script that inserts the users identity, doesn´ t work as soon as it is being copied to another pc.
As you know, the user-created stamps are being saved at "C:\Users\User\AppData\Roaming\Tracker Software\PDFXEditor\3.0\Stamps" by Tracker Software Products and everything seems to be just fine with the dynamic stamp that contains only time and date as it is being copied onto another users pc.

Let´ s say there are two users on different notebooks and they´ re both using the same software and the same products.
User "A" creates two dynamic stamps - one containing time and date only - and another one containing only the identity.
User "A" uses the javascript from above as a resource.
As user "B" copies user "A"s stamps and inserts them into his directory, user "B" has now aquired both stamps and is now able to use them, but user "B" only gets user "A"s identity as soon as he uses the stamp.

--
I´ ve already consulted a friend of mine about this specific topic and he told me that there might just be some compability problem.

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 10:01 pm
by TrackerSupp-Daniel
Hello LFlat,

Please try the Stamp ive attached below, which is using the code I copied directly from your earlier post, You will see that upon selecting the stamp, it does show the incorrect name in the palette:
image.png
image.png (12.5 KiB) Viewed 9609 times
However upon placement, that is updated correctly on a per-user basis (my colleague Cody helped with this test):
picturemessage_dfd5vgui.oyf.png
picturemessage_dfd5vgui.oyf.png (14.36 KiB) Viewed 9609 times
This is because the image the Stamp uses is from the time when the Stamp was created. This was an intentional change a few builds back as dynamic check in the palette was causing some issues, and disabling it did not affect the placed stamps in any way. However the Devs are now looking into it to see if we can resolve that issue to bring it back for you. I cannot make any guarantees at this time, only a promise that we are going to look into it.

For now, you will likely wish to inform your users that the stamp with your name on it is they one they should use, as it will update when they place it.

You may also wish to look over this KB article and its reference articles for more information: https://www.pdf-xchange.com/knowle ... p-Creation

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 11:30 pm
by LFlat
Thanks! I just tried using the stamp you created and it worked just fine, but I still don´ t get it.
(Hope you don´ t mind @Daniel .....)

"Please try the Stamp ive attached below, which is using the code I copied directly from your earlier post, You will see that upon selecting the stamp, it does show the incorrect name in the palette:
However upon placement, that is updated correctly on a per-user basis (my colleague Cody helped with this test):"

Do you mind sharing the precise code you inserted for that stamp? - It did not work as I tried the script above with my colleague.

Thanks in advance!

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 11:43 pm
by TrackerSupp-Daniel
Hello LFlat,
If you open the document that I've sent, you can see the JS simply by inspecting the properties of each form field:
image.png
image.png
I did not change, modify or write any code personally whatsoever, I copied it directly from your post, and pasted directly into the JS window for the form field, then saved the document.

As I had mentioned before, the image within the palette will not change, Can you please verify if the user is saying that it does not work when placing the stamp, or only that it does not look like it worked in the palette?

Re: Add an identity and time to a dynamic stamp

Posted: Mon Jan 14, 2019 11:58 pm
by LFlat
I can verify that the identity has not changed after my colleague used the stamp I made.
(That´ s why I´ m that confused.)
Well, I´ ll just try it tomorrow and see if anything changes.
If it doesn´ t work, I´ ll just have to look into it myself a bit more - also, if I happen to find no answer, I´ ll just ask you guys instead. :P

Thanks a lot @Daniel, if I were to give you a recommendation, it´ d be a 10/10.

Best regards

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 12:04 am
by TrackerSupp-Daniel
Hello LFlat,

I just realized, we haven't verified, Does the use have anything set in their Identity fields within the Editor?
image.png
At least one of these two fields must be filled, as these are the fields you are calling on when the stamp is placed, otherwise it will simply use what already exists in the stamp.

I hope that helps!

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 12:13 am
by LFlat
Yes, the login is set, but the name isn´t. Although I´ve even got another question concerning this topic.
As I am not used to working with javascript, I´ d like to have both of the scripts used in a single text-field.

Thanks

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 1:07 am
by TrackerSupp-Daniel
Hello LFlat,

Thankfully It has been a slow day and I had time to do this. It took a bit of jimmying, but I managed to get the script to be much smaller, and do both actions for you, in a single field:

Code: Select all

var clk = util.printd("dd.mm.yyyy HH:MM", new Date);
var iden = identity.name || identity.loginName;
event.value = iden.concat("	",clk);
Note that I used a single Tab character as a spacer, this will allow the field to emulate the name being left bound, and the time being right bound (or gives enough push for a multiline solution). The concat method was needed, so I had to create a variable each for the clock (clk) and the identity (iden). This let me combine the strings together in a single output, which fields need as there is only one output location, so any later output simply overwrites the original.

This does not have the replace functionality you were using before, but you could certainly add it back in if you choose.
The Or statement will only use the second field if the first returns no value, so you do not need to worry about accidentally using the login name instead of the user name.

I hope it helps!

Edit: I figured a screenshot showing the output might be appreciated:
image.png

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 1:23 am
by LFlat
Thanks again Daniel, but as it's already 2am by now, I'll have to wait at least a couple of hours to test it.

If you mean the scripts ability to set the user as it's being used as the replace functionality, then I'm afraid I've got no use for the script posted above.

Thanks again, I'll test it asap (approximately at 7am).

(Oh, and I'll probably input the following...)
[User, Time, Date]

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 10:42 am
by LFlat
Thank you guys for the support!
Everything worked out just fine with the script and advice you provided me with @Daniel.

Kind regards

Re: Add an identity and time to a dynamic stamp

Posted: Tue Jan 15, 2019 11:54 am
by Tracker Supp-Stefan
:)