How to Display the Current Windows Username in an Acrobat PDF Form
Question details
The user wants to automatically insert and display the current Windows username when opening an Acrobat PDF form.

- Product
- Adobe Acrobat
- Device & OS
- Windows
- Scenario
- Creating or configuring a PDF form that needs to automatically populate a text field with the local user's operating system username upon opening.
- Observed behavior
- Acrobat PDF forms cannot directly read the Windows username via standard document-level scripts due to security restrictions, requiring alternative deployment methods.
Ensure you have administrative access to the computers where the PDF will be opened, as reading operating-system environment variables securely requires deploying trusted local script files.
Deploy a Trusted Folder-Level Script File
Use a folder-level trusted JavaScript to safely access the Windows username and pass it to the PDF form.
Because accessing environment variables like the Windows USERNAME poses a security risk, Acrobat prevents document-level scripts from reading this data directly.
To bypass this limitation safely, you must create a privileged JavaScript file and place it in the Acrobat application's local JavaScripts folder on each user's machine.
Open a plain text editor like Notepad and write a JavaScript function using `app.trustedFunction` to retrieve the `identity.loginName` or relevant system environment variable.
Save the text file with a `.js` extension (for example, `GetUsername.js`). Ensure the file type is set to 'All Files' to prevent it from saving as a `.txt` file.
Copy the `.js` file into the Acrobat application's local JavaScripts directory on each user's computer (typically located in `C:\Program Files\Adobe\Acrobat DC\Acrobat\JavaScripts`).
Open your PDF form in Acrobat, navigate to the document-level JavaScripts or a Page Open action, and call the trusted function you created to populate the target form field with the retrieved username.

Use Manual Form Entry for Untrusted Environments
If you cannot deploy local scripts to every user's computer, asking users to type their name manually is the most reliable fallback alternative.
Create, Edit, and Manage PDF Forms Easily with WPS Office
WPS Office provides a comprehensive and user-friendly PDF editor. Instead of dealing with complex local JavaScript configurations, use WPS Office to quickly build interactive PDF forms, insert required text fields, and share documents safely without advanced deployment hurdles.
- 1. Open WPS Office: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form creation and editing tools.
- 3. Add Fields and Share: Insert text fields for users to enter their information securely, then save and distribute the PDF file.

Frequently Asked Questions
Why can't a PDF document read my Windows username directly?
For security and privacy reasons, standard PDF documents are sandboxed and restricted from accessing sensitive operating-system environment variables, such as your username or directory paths, to prevent malicious scripts from stealing personal data.
What is a privileged Acrobat JavaScript context?
A privileged context is a higher security execution level in Acrobat. Scripts running in this context (like folder-level scripts installed locally on a machine) are trusted by the application and can execute actions that standard document-level scripts cannot, such as reading local system data.
Can I use document-level JavaScript to get the login name instead?
No, a standard document-level script alone cannot access the `identity.loginName` or `USERNAME` variables safely. You must combine it with a folder-level trusted script deployed locally on the user's device.
Is there a way to automatically fill usernames on mobile devices?
Automatically fetching OS-level usernames via JavaScript is generally unsupported on mobile PDF viewers due to strict sandboxing on iOS and Android platforms. Manual entry is the recommended approach for mobile users.




