• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do you link text fields to QR codes in InDesign?

Community Beginner ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Hello, I am laying out labels using InDesign, the labels have a lot# that often changes (in it's own text field).  I would like this lot # to be the text that comes up when the QR code is scanned.  I can manually input the text into the QR code text box.  I would rather have the QR code change when the text is changed though.  If anyone knows of a way to write it so that the QR code always shows what is in the specified text box, it would be amazing.  Thank you for your time.  

TOPICS
Feature request , How to , Print , Scripting , Type

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 13, 2021 Dec 13, 2021

Hi @Sean22153274qbmh, I'm wondering if there's been a slight change to the script between encoding on this web page, displaying in your web browser and copy/pasting into Notepad, etc. I've sent you a private message with a direct link to the script. Please try that first, just to rule out that possibility.

- Mark

Votes

Translate

Translate
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Off hand, you could do this with Data Merge. Have a field for the text, and a duplicate field that creates the QR code. 

 

This would not be a dynamic document, but it would be easier than hand-entering the text.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Thank you SJRiegel,

 

That would save some time.  An ideal situation would be that the text field could be updated in the PDF using acrobat (for ease of use and time) or InDesign.  I am also open to using illustrator or other abode products, if that helps.  I have not fully explored the illustrator plug-ins for QR codes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Does the lot# need to be a QR code? If not, barcodes like 39 and 128 could be generated with a font, and then you could have a dynamic situation where entering data once and populate in many.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

You could also look at a paid solution like BarcodeMaker from Teacup Software. They offer a free trial and good documentation. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2021 Dec 08, 2021

Copy link to clipboard

Copied

Your problem seems quite solvable via scripting. Do you have any experience with scripting? Let me know if you'd like some help. Or maybe post an example of a page of labels and we could see what could be done.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 09, 2021 Dec 09, 2021

Copy link to clipboard

Copied

m1b, 

 

Thank you so much, I was also thinking there may be an easy scripting or coding answer, I am just not familiar with scripting and have not been have not been able to solve the issue with my research so far. I am including an image, at this point I am just trying to figure out a good procedure before handing off the project to my companies pre-press department. 

 

At the very base level, I am just looking for one 5 digit number ( lot number field, highlighted in image) to translate to the QR code.  I was also thinking of setting up the labels with a master page that has lot# and QR code.  The child pages would have each individual size for the product.  Either scenario though, it's really just one place in the document (QR code), that I am hoping to translate one number to (lot #).   Please let me know if I can provide more information or images.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 09, 2021 Dec 09, 2021

Copy link to clipboard

Copied

Hi @Sean22153274qbmh, I've written a script that I think may solve this problem quite well. See instructions in script listing, and let me know what you think.

- Mark

 

/*
    Update QR-Codes with Styled Text
    for Adobe Indesign

    by m1b
    here: https://community.adobe.com/t5/indesign-discussions/how-do-you-link-text-fields-to-qr-codes-in-indesign/m-p/12582394

    Instructions to set up one updatable QR Code:
    (Do these steps again for each updatable QR-Code.)
        1. Make a text frame:
            • containing your text contents that will be used to update a QR-Code
            • set in a Character Style that the script will use to find updatable QR-Codes
        2. Choose Object > Generate QR Code... and place and scale the QR-Code to suit you
        3. Group the text frame from (1) and the QR Code Graphic from (2).

    Instructions to configure script
        1. character style name below must match the Character Style name in (1)
        2. swatch name supplied below will be applied to the updated QR-Code in (2)
            (comment out that line to use default swatch color)

*/

function main() {

    updateQRCodesWithStyledText(
        /* document to update */
        app.activeDocument,

        /* character style name */
        'Update QRCode Style',

        /* qr code swatch name (optional - comment out next line to use black) */
        'My Swatch Color'
    );

    function updateQRCodesWithStyledText(doc, characterStyleName, qrCodeSwatchName) {
        app.findGrepPreferences = NothingEnum.NOTHING;
        app.changeGrepPreferences = NothingEnum.NOTHING;
        app.findGrepPreferences.appliedCharacterStyle = characterStyleName;
        var texts = doc.findGrep();
        for (var i = 0; i < texts.length; i++) {
            if (!texts[i].hasOwnProperty('contents')) continue;
            var qrCodeGraphic = texts[i].parentTextFrames[0].parent.allGraphics[0];
            if (!qrCodeGraphic.isValid) continue;
            qrCodeGraphic.createPlainTextQRCode(texts[i].contents, qrCodeSwatchName);
        }
    }

} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update QR-Codes');

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Thanks so much for taking the time to do that.  I tried out the script by pasting it into Notepad++ and outputting as a javascript file.  When I go to lauch the script from the script panel, I get the following error.  To be honest, I'm not sure how to define the app here.  it is just a command to run the script right?

 

Sean22153274qbmh_0-1639411094697.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Just to clarify, line 29 is:

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update QR-Codes');

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Last line should be enclosed in parentheses, and to be safe end in a semicolon): 

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update QR-Codes');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Thanks I tried adding a set of parenthesis, but I'm still getting the same error.  I tried with Brackets as well, not sure why it is not liking this last line.  I'm very much a  beginner at scripting though 

 

(app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update QR-Codes'));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

You said line 29 was: 

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, '

It should be: 

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update QR-Codes');

No surrounding parentheses. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 13, 2021 Dec 13, 2021

Copy link to clipboard

Copied

Hi @Sean22153274qbmh, I'm wondering if there's been a slight change to the script between encoding on this web page, displaying in your web browser and copy/pasting into Notepad, etc. I've sent you a private message with a direct link to the script. Please try that first, just to rule out that possibility.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

Thank you for the help everyone, especially Mark.  This is my first post so hopefully this is an okay way to end it.  I was initially thinking their may be a way to type some simple text or one line of code into the QR code menu in InDesign.  With the scripting I am still new to it.  Throughout exploring InDesign further, I found some other ways to automate our label creation.  Inputting the same number in two fields no longer seems like such a burden and I got the okay from management to proceed in this fashion.  I did try out the new code to no avail, I got the same message about the last line.  But I think that could be due to my inexperience with scripts.  I'm going to mark this as complete because I feel like the question has been answered.  Linking text fields can be done, but requires the use of additional scripts.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

Glad you have a way forward! I'm sorry to hear you didn't get the script to work though, and I'm curious to know what happened. Do you mind telling me what version of Indesign are you using? And operating system? The error message you saw doesn't shed any light for me.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

Hi Mark,

 

Sorry for the delay.  I was off of work most of the last week.  I am running InDesign 2022, connected to the creative cloud.  Windows 10 for the operating system.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks for replying. I tested only on Mac OS Indesign 2022 and I don't have access to a Windows 10 installation.

Can anyone else reading this try script on Windows 10? I have had another forum user report a similar error on a different script on Windows and I'd love to get to the bottom of it.

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines