QR code object doesn't display encoded value when passed from a .net application
Copy link to clipboard
Copied
I have a PDF template with form fields in Adobe Acrobat that has a barcode object set to QR code. There is a hidden textbox that contains the information the QR object is supposed to encode-in my case it is a shortened URL that will change depending on the item name. When I edit the PDF and manually set the hidden textbox to the URL, the QR code updates just fine and directs to the proper site. However, the QR object will not update and display correctly when I pass the URL into the textbox through a vb.net application. It's passing the same value as what I manually entered and I even set the form field manually in the application just in case there was a discrepancy in the value I was retrieving from SQL. I have also tried changing the value to a custom calculation script and making sure the textbox values passes as a String. The QR code still will not update and displays only the textbox's field name; sometimes it won't scan at all.
I have not been able to find any answers online that deals with this kind of problem. Any suggestions?
Copy link to clipboard
Copied
The PDF appearance of the Barcode field can only be updated by an application that is displaying the PDF at the time the barcode value is changed, understands how the barcode needs to be updated, and has the capability to do so. Basically Acrobat Pro. Possibly one of the better PDF viewers or one of the Adobe server side apps/services.
Acrobat Reader will not update the barcode because it requires special "Reader Rights" to do so. Nearly all mobile apps and web browsers completely worthless when it comes to PDF forms, and espeically the more specialized PDF form elements.
So how exactly is this vb.net app updating the barcode value?
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hm, so even if I am using Adobe Acrobat to open the PDF once those values have been passed, it still won't display the correct QR code because the application that updated it wasn't Acrobat? Is there any way to dynamically change a QR code on a PDF then?
I am using form fields, PdfReader/PdfStamper, and AcroFields to pass information to the PDF template.
Copy link to clipboard
Copied
Yes, you should be able to "Kick" Acrobat to update the barcode field.
You said that the value is loaded into a separate text field, and that the barcode field uses a calculation script to grab this value. If so, then try putting this line in a document script:
this.calculateNow();
This only works if the barcode Value is not already set to the new value. So if this isn't working, then delete the calculation script and use a manual copy in the document script
this.getField("Barcode1").value = this.getField("Text1").value;
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
I've tried both of these scripts and the QR code doesn't update when Acrobat is opened. It will update when I go into the properties of the object, change something, and save however.
Copy link to clipboard
Copied
Seems like the calculation is not getting triggered.
Try this. Remove the scripts (anything that might affect the barcode or hidden field), then run your server side filler. Open the PDF in Acrobat and see what the values are in both the barcode and the hidden field.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
The hidden field is set to the URL and the barcode says it's pointing to the hidden field but it has a blank value.
Copy link to clipboard
Copied
Without seeing your file it's hard to tell why the value is not being copied over automatically. One solid solution is to do the copy explicitly from a button script. Not ideal, but it will work.
If you want to do further debug on the automatic technique you'll need to put some console.println statements in the code to see what is triggered when. You could even try a document script that compares the barcode to the hidden field and forces a transfer if they are different.
Here's a video tutorial on using the console for debug.
https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Hello Mr. Parker... not sure if your in the same compacity from approximately a little under a year ago from seeing when this was posted but I too have a similar situation but a bit different. I have a dynamic pdf form that has a qr code that has been created and is printing the user attributes incorrectly. You would think the qr code output would print correctly because the Hierarchy is in order per each field as well as the Collection List. Everything checked is within this list. To make matters even more confusing is that there is a previous file that works & it's almost identical to the file that I'm working on albeit verbiage changes: Collection List, Hierarchy, the value of the barcode which is (Automatic Scripting, Delimited format, Pipe, UTF-8 Char. Encoding, etc.) Everything is identical. Why is one field out of order when this barcode is scanned is what I'm having trouble with.
I have both files that you can checkout with even the test output cases in a text file however, do not have the software/device used to scan this code. Piggying back on my previous statement is why I'm kinda working in the dark here. Here's the caveat... I cannot test this once this change is implemented. I have to call/email the client to print & test the file. So, I'm not exactly sure how they're printing this nor am I certain on what type of software/device they're using to scan. I tried so many things and now I'm trying to build some test cases for him to try. For example, Print this form a certain way or something else I can try on my end?
Needless to say, I am stumped. Created another post but noone has commented yet so just doing another attempt in that regard. Thanks for your attention to this matter if at all. Will send the files upon comment.
Copy link to clipboard
Copied
If this is an AEM form, then the question needs to be asked on the AEM forum.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
It is... & I have. Thanks!

