Wednesday, 29 August 2018

Show login name of the user

How to get the Username/ Login Name of the user who filled the form?

Due to security reason in PDF, this task becomes quite difficult to achieve and is only feasible for the intranet environment.
Firstly, you need to create a Trusted Function at the folder level script which checks the login name and returns the value to a form field. Here the hierarchy of the LC form is important. The result will map to the specific field in the form.

Place the following script in the Javascript folder of Acrobat or Reader depending on your requirement:
For Example:
C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts
Or,
C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\Javascripts


var TrustMe = app.trustedFunction(function(doc){app.beginPriv(); var IdentField = this.xfa.form.Form1.Page1.LoginUserName;IdentField.rawValue = this.identity.loginName;  app.endPriv(); });

Now, the main part is done and you just need to call the function which is placed at the folder level JavaScript.  

Put this script in the form:ready event of the form or any button to call the function
 

event.target.TrustMe(event.target);

Show Login Name


Download the files from the following link and place the .js file at the JavaScripts folder mentioned above and then open the PDF and click "Get" button.

Source: https://www.dropbox.com/s/qwtvpsv68ocxdvy/GetUserName.zip?dl=0

No comments:

Post a Comment