How to Dynamically Add a File Name QR Code to PDFs in Adobe Acrobat
Question details
The user wants to automate adding a QR code that contains the current PDF's file name into an open document.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automatically generating and placing a QR code reflecting the document's file name within a PDF file.
- Observed behavior
- Needs a script or specific method to dynamically bind the file name to a barcode or QR code field within the document.
Ensure you have access to the Prepare Form tools and JavaScript console in Adobe Acrobat Pro, as standard PDF readers do not support advanced scripting and barcode field creation.
Bind the File Name to a 2D Barcode Field using JavaScript
Use Adobe Acrobat's form editing features to create a 2D barcode and set up a document-level script to populate it automatically with the current file name.
By creating a 2D barcode field, you can leverage Acrobat's built-in JavaScript engine to pull the document's file name and encode it. Keep in mind that this script runs within Acrobat itself, meaning if the file is renamed outside of Acrobat, the QR code will not update until the file is opened again in a compatible PDF editor.
Open your PDF in Adobe Acrobat and navigate to the 'Prepare Form' tool from the right-hand pane or the Tools menu.
Select the Barcode tool from the form toolbar and click and drag on your document to draw a field where you want the QR code to appear.
Double-click the barcode field to open its Properties. Name the field specifically (e.g., 'BarcodeFieldName'). In the Options tab, set the Symbology to 'QR Code'.
Go to 'Tools' > 'JavaScript' > 'Document JavaScripts'. Add a new script and name it.
Enter the following code to bind the file name to the QR code: `this.getField('BarcodeFieldName').value = this.documentFileName;` and click OK to save and execute.

Manage and Edit PDFs Effortlessly with WPS Office
While advanced JavaScript triggers require expensive premium PDF editors, WPS Office provides a lightweight, comprehensive, and free alternative for managing, editing, and annotating PDFs, along with seamless compatibility for Word, Excel, and PowerPoint files.
- 1. Download the Installer: Visit the official WPS Office website and click on the free download button.
- 2. Install WPS Office: Run the downloaded installer and follow the on-screen prompts to set up the software on your device.
- 3. Open Your PDF: Launch WPS Office, select the PDF tab, and open your document to start editing or annotating immediately.

Frequently Asked Questions
Will the QR code update automatically if I rename the file on my desktop?
No. If you use a barcode field powered by JavaScript, its value cannot be updated outside of Acrobat. When you rename the file on your desktop, the QR code will only update the next time you open the file in Acrobat and the background script runs.
Do I need Adobe Acrobat Pro to create a dynamic QR code?
Yes, you need a premium version of Adobe Acrobat (such as Pro) that includes the 'Prepare Form' tool and allows adding Document JavaScripts. Standard PDF readers do not have these form authoring and scripting capabilities.
Can I insert a static QR code instead of a dynamic one?
Absolutely. If you do not need the QR code to update dynamically based on the file name, you can use any free online QR code generator to create an image of your QR code, and then use the 'Add Image' tool in your PDF editor to place it onto the document.




