PDF Editing Issues

How to Dynamically Add a File Name QR Code to PDFs in Adobe Acrobat

Aamir Naveed AkramAamir Naveed Akram Nov 24, 2026 868 views

Question details

The user wants to automate adding a QR code that contains the current PDF's file name into an open document.

How to Dynamically Add a File Name QR Code to PDFs in Adobe Acrobat
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.
Before you start

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.

Solution 1Recommended

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.

1
Open Prepare Form Tool

Open your PDF in Adobe Acrobat and navigate to the 'Prepare Form' tool from the right-hand pane or the Tools menu.

2
Add a Barcode Field

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.

3
Configure Barcode Properties

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'.

4
Add Document JavaScript

Go to 'Tools' > 'JavaScript' > 'Document JavaScripts'. Add a new script and name it.

5
Enter the JavaScript Code

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.

Bind the File Name to a 2D Barcode Field using JavaScript
External File Renaming Limitation: If you rename the PDF file using your operating system's file explorer, the QR code value will only reflect the new name once the document is reopened and the script executes within Acrobat.
Free Microsoft Office alternative

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. 1. Download the Installer: Visit the official WPS Office website and click on the free download button.
  2. 2. Install WPS Office: Run the downloaded installer and follow the on-screen prompts to set up the software on your device.
  3. 3. Open Your PDF: Launch WPS Office, select the PDF tab, and open your document to start editing or annotating immediately.
Comprehensive PDF tools for reading, editing, annotating, and signing documents.Seamless format compatibility with Microsoft Word, Excel, PowerPoint, and standard PDF files.Lightweight architecture ensures fast loading and smooth performance on older hardware.Familiar, easy-to-use tabbed interface for a seamless migration from other productivity suites.
microsoft office alternative - wps office

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.