javascript registered username ?  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
cockerarea
User
Posts: 5
Joined: Tue Sep 15, 2020 3:50 pm

javascript registered username ?

Post by cockerarea »

Hi to everybody
New on this forum ans certainly newbie with the XCHANGE program, I need your help

I'm trying to create a dynamic stamp with the date/hour but also the name of the registered user.
I found an example of script using ...

((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name)

but it gives the username of the windows session, that's not really explicit in my case (company policy)

Could you give me a script giving the first and last name of the registered user (= me!)
I understand that I could place my name directly in the text field, but would like something more portable

Thanks for your help :D
User avatar
TrackerSupp-JohnG
Site Admin
Posts: 18
Joined: Tue Sep 15, 2020 11:43 pm

Re: javascript registered username ?

Post by TrackerSupp-JohnG »

Hello,
In order to use a dynamic stamp with the desired name, what you shall have to do is the following;
1) Select 'FILE>PREFERENCES>IDENTITY.'
2) Enter the name you wish to use in the name field.
3) Ensure that the box 'Get the information from the Active Directory' IS NOT checked.
PDFXEdit_pse7UEqsvk.png
Hope this helps you,
John Gareth
Support Technician
Tracker Software Products (Canada) LTD

Support: <Support@tracker-software.com>
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
cockerarea
User
Posts: 5
Joined: Tue Sep 15, 2020 3:50 pm

Re: javascript registered username ?

Post by cockerarea »

Thanks John ... indeed it's what I was searching for :D
could you give me an example of a script using all of these inputs ?
(name, company, dept, ...)
I'm a newbie in javascript and don't know anything about it :?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: javascript registered username ?

Post by Tracker Supp-Stefan »

Hello there,

The script you have included in your initial post seems to be taking care of this.
If the name which John showed you is entered - it will be used (identity.name), and IF that is not set up - then the Windows username (identity.loginName) will be used instead as a fallback.

So that script you have should already work, and the use of the Windows user name is just a safety measure so that you can have a value to use if the identity.name has not been properly set up by the person using your script on their machine.
JS can be used to make changes to the identity.name value, as it is both Readable and Writeable, while the identity.loginName is a read only value.

Kind regards,
Stefan
cockerarea
User
Posts: 5
Joined: Tue Sep 15, 2020 3:50 pm

Re: javascript registered username ?

Post by cockerarea »

thanks for your reply, but I would like to user also other fields such as
- company name
- department
- email address
that I have entered in the fields that John ...
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: javascript registered username ?

Post by Tracker Supp-Stefan »

Hello there,

You have four properties under identity:
identity.name
identity.loginName
identity.corporation
identity.email

We can point you in the right direction but would not normally write the whole script for you, so if you want to use JS you are expected to have some knowledge yourself.
You can read more about the identity method and it's properties here (page 491):
https://www.adobe.com/content/dam/acom/ ... erence.pdf

Kind regards,
Stefan
cockerarea
User
Posts: 5
Joined: Tue Sep 15, 2020 3:50 pm

Re: javascript registered username ?

Post by cockerarea »

you're wonderful !
great, I found how to add all the fields that I need, to my stamp

just still searching the two last fields:
- title
- unit
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: javascript registered username ?

Post by Tracker Supp-Stefan »

Hello there,

I am afraid that
identity.unit
and
identity.title
are not described in the JS specification.

I spoke with the Project Leader for the Editor, and after he did some of his magic - we found out that there are two extra (undocumented) identity properties:
identity.title
and
identity.department (the "Organisation Unit" you see in the preferences window)
So we will be working on adding support for those two in a future build of the Editor as well.
#5327: Editor: Add JS support for identity.title and identity.department

Kind regards,
Stefan
cockerarea
User
Posts: 5
Joined: Tue Sep 15, 2020 3:50 pm

Re: javascript registered username ? --> current file name?  SOLVED

Post by cockerarea »

Hi'

I've another problem about dynamic stamps.
I would like to insert the file name of the document on which I put the dynamic stamp...

I searched on Google, and found ...

1) event.value = This.DocumentFileName, but when I put the stamp on a file, it gives the name of the "stamps ref files"
2) event.value = event.source.source || this.documentFileName , but gives something I don't understand (like "[Object Doc]")

Could you help me please ??

Thank you very much, and my best wishes for 2021 :-)
UPDATE :

it works with

event.value = event.source.source.documentFileName.replace(/\.pdf$/i,"");

(giving the file name without the PDF extension)
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: javascript registered username ?

Post by Tracker Supp-Stefan »

Hello Spam message posted by BOT engine - ignore - to be deleted by admin,

Many hanks for sharing this here! Hope it us useful to others as well!

Kind regards,
Stefan
Post Reply