Skip navigation
Currently Being Moderated

[Ann] QR Code for InDesign CS4 and up

Oct 19, 2012 5:07 PM

Tags: #cs4 #cs5 #javascript #indesign #code #cs6 #qr

Ever needed to create a QR code? There are literally hundreds of free QR code generators on the web, but they all have the same drawbacks:


1. They typically deliver a PNG, either 'click here to download', or you have to drag it somewhere yourself.

2. It's typically an RGB image, so the cautious designer will start up Photoshop to convert it to a monochrome image.

3. .. so you get a file to store somewhere ..

4. ... and after seeing four of them you cannot remember which QR code said what ...

5. .... and, you cannot use such site in a batched environment (well, maybe some people can by building a proper URL, call the website, wait for a response, etc. I bet it's difficult for your average scripter.)


So I had a go on converting one of the existing Javascript solutions -- Patrick Wied's, in case you're curious -- into a construction fit for InDesign. All you have to do is download the zip: -- unpack it, and save the file "QRCode.jsxbin" in your local User Script folder. It ought to be compatible with InDesign CS4 and upwards, for both Mac and Windows.

When it appears in your Script Panel, you can double-click to run and


1. with nothing selected, it prompts for text and error recovery settings, and will place a proper monochrome TIFF bitmap of (approximately) a useful dimension in the center of your current page.


2. with an empty rectangle selected, the new QR code will be placed inside it.


3. with some text selected, the text field will be pre-filled with this.


4. With a QR Code selected which you created earlier using this same tool, the text field will contain the original text, and the quality setting will be retrieved. You can cancel the dialog if you only wanted to know what it said, or change the text or quality.


5. You can call this script from another script to perform batch operations. It accepts two required arguments, and one optional, in this order: text, Error Correction level (1-4), and optionally a destination rectangle to place it in:


app.doScript(new File(app.activeScript.path+'/qrcode.jsxbin'), ScriptLanguage.JAVASCRIPT, ["hello", 1, app.selection[0]], UndoModes.ENTIRE_SCRIPT, "Call QR Code");


6. Since it's a monochrome bitmap TIFF with enough resolution (at its default size it's 200 dpi), you can use the swatches palette to change the white or black parts to another color, or even make one transparent.


7. It's just a small file, and so I decided to always have it automatically embed. That way you can never loose it. The image first has to be created in a temporary file (default location: (Temp)/qrcode.tiff, where (Temp) is your local Temporary Files folder). If this fails for some of you (there always seem to be overly prudent IT professionals who seem to despise users storing files willy-nilly), I'll have to think of something else.


Note: this version only supports plain text mode, not numeric, alphanumeric, or Kanji. Text is converted to UTF-8; for the most common purpose -- web pages -- it should work normally.




Based entirely on Patrick Wied's implementation of a basic QR Code generator. Patrick Wied dutifully notes


I do not guarantee any resulting QR code generations or detections, use this application at your own risk! - this project is just a study project (non commercial).


and so I advise to always check your generated code using a good QR Code reader.

  • Currently Being Moderated
    Oct 19, 2012 11:24 PM   in reply to [Jongware]

    looks like it's working to me... wow!


    I don't have a smartphone to check the QR code and the iMac can't read the QR code with the inbuilt cam without Quickmark, but did find an online "decoder" to check the QR code generated.


    After unembedding the QR code, I went to and submitted the qrcode.tiff which was  generated... which it didn't like. resaved the tiff as a png via photoshop and tried again... worked that time!



    Mark as:
  • Currently Being Moderated
    Feb 24, 2013 1:35 PM   in reply to [Jongware]

    To give back to community, here is the script to generate QR codes for business cards created by data merge

    It reads text frames starting with MECARD:, empties them and places QRcode rotated 15 degrees counterclockwise. Enjoy!


    var _d = app.documents[0];

    var _allStories = _d.stories;

    for(var nx=_allStories.length-1;nx>=0;nx--){

        var _storyAllTextFrames = _allStories[nx].textContainers;

        for(var mx=_storyAllTextFrames.length-1;mx>=0;mx--){

             _storyAllTextFrames[mx].select(); // change page


                 var obj = app.doScript(new File(app.activeScript.path+'/qrcode.jsxbin'), ScriptLanguage.JAVASCRIPT, [_storyAllTextFrames[mx].contents]);

                 _storyAllTextFrames[mx].contents = "";

                var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:.7,


                obj.transform(CoordinateSpaces.pasteboardCoordinates,AnchorPoint.cent erAnchor, myScaleMatrix);            


                 //obj.move ([_x,_y]);






    here is a MECARD template for you:







    NOTE:<<Position>> at <<Company>>;



    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 4:11 AM   in reply to sergemca

    I like this use of the script that sergemca has provided. It doesn't perform the text-to-qrcode conversion on the fly as the document is being merged, but rather takes a merged file and applies qrcodes to any textframe that begins with MECARD: . Having said that, the script could also be applied to any large document that has textboxes with the MECARD: rule as outlined in the above post, a merged file is but one example.


    Having said that, would a text frame that had a script label be more appropriate e.g. rather than the script hunting for any instance of a textbox with the words MECARD: in them, could an alternative be to look for textframes that have a similarly named script label? The advantage of this would be that the QRcode would not include the words "MECARD:" when made (or any other text trigger) that is in the script at the moment. What would have to change in the above script to accomplish this?


    Nevertheless it is a brilliant script, well done.



    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 6:46 AM   in reply to [Jongware]

    OIC. Must admit to not owning a smartphone and being unaware of the MECARD detail


    I felt that sergemca's script had more potential than files assembled out of data merge, and could be used for any document where particular placeholders were set up, regardless of how the document was created. For example, a parts catalogue that has URLs for each product, whether created from scratch; as a result of data merge or XML; could benefit from this script by employing a method similar to my last post.


    In terms of data merge, if it is used off-of-the-shelf, it can't auto-generate text frames of its own based on the incoming data. I've been able to get data merge to do some weird and wonderful things as outlined on my blog, but the possibilities with scripting and data merge are yet to fully be explored. Loic Aigon is a pioneer with this, he has several scripts that push the envelope and do things outside the normal scope of data merge, but apart from what he's done, i'm not sure of its further potential.

    Mark as:
  • Currently Being Moderated
    Mar 18, 2013 1:45 PM   in reply to [Jongware]

    I work for Meadows Publishing Solutions and we have released an updated version of our 2D Bar Code Module for Adobe InDesign with a FREE license option for producing QR codes. This new software module is designed to generate QR Code, Data Matrix, and PDF417 two-dimensional bar codes directly in any Adobe InDesign document.


    To help introduce the product, we are currently offering a FREE license of the module which is limited to the production of QR codes. The free license can be obtained by visiting


    Of course, our hope is that for clients that wish to automate the QR Code creation process via Excel spreadsheets or data files, they might consider a purchase of our DesignMerge variable data software, but this is certainly not a requirement.

    Mark as:
  • Currently Being Moderated
    Apr 25, 2013 5:18 PM   in reply to sergemca

    This is an awesome script, but I have 3 questions and any help would be appreciated. I've been trying to reverse engineer different scripts to duct tape what I want together, but no luck. So here goes:


    How would I go about resizing the actual QRCODE to 56px x 19mm?

    How would I reposition this from an area other than the center like 256px x 114mm?

    How could I recolor it with a swatch in my pallete?



    Any help would be deeply appreciated,


    Mark as:
  • Currently Being Moderated
    Apr 27, 2013 7:48 AM   in reply to [Jongware]

    Thank you so much for your reply Jongware. I appreciate your help. Yeah, I agree that 19mm is small, but I was using the info panel in Indesign and it had pixels for the width and mm for the height and couldn't quite figure out a way to have the info be all in pixels.


    I'll work with example you provided me and see where it gets me.


    Thanks Again!

    Mark as:
  • Currently Being Moderated
    Apr 28, 2013 10:29 AM   in reply to [Jongware]

    Thank you Jongware, your example was a great teaching tool.


    I was able to implement this using the MECARD example provided from sergemca, but when trying to do it with VCARD, it doesn't work. The scan works when it is produced directly from the QRCODE.jsx script and input directly into the JONGWARE QRCODE GENERATOR, but not with the customized version reading the data from the textframe. The QRCODE is created, but when scanned, it just brings up the contact area in my phone, but no data. Note: I did update the script to look for BEGIN:VCARD, which is the same as what I input directly. The QRCODE appears, but doesn't bring in any data when scanned.


    Any ideas why this would work differently when entered directly or from a textframe?


    Here is the VCARD code I'm using:





    FN:Jimalya Smith

    TITLE:Some Title

    ORG:Some Place



    Mark as:
  • Currently Being Moderated
    Apr 29, 2013 4:51 AM   in reply to [Jongware]

    Thank you so much for your help! I'll keep researching.


    Matt Pleasant

    Mark as:
  • Currently Being Moderated
    Apr 30, 2013 1:55 AM   in reply to [Jongware]

    @Jongware – just to complement the topic of generating QR codes in InDesign, see the following sneak peek of InDesign CS(next*) by John Nack:





    *we will have to wait a bit longer to know how it will be named exactly… My guess is: "CS7".

    Mark as:
  • Currently Being Moderated
    Apr 30, 2013 2:27 AM   in reply to [Jongware]

    Oh boy!
    Creating QR codes in InDesign seems to be a top priority feature ;-)
    Last-In-First-Out principle?



    Mark as:
  • Currently Being Moderated
    Apr 30, 2013 7:40 AM   in reply to [Jongware]

    Imitation is the sincerest of flattery.

    Mark as:
  • Currently Being Moderated
    Jun 23, 2013 11:04 PM   in reply to [Jongware]

    Nice work. You might find some useful code in the 'zend-framework-matrixcode-module', its used to generate vector eps and pdf QR codes on



    Mark as:
  • Currently Being Moderated
    Mar 15, 2014 7:43 PM   in reply to Ampersand et



    Thank you for your contribution of this script and for all that you do for the Adobe community. This script works like a dream!


    Kindest regards,



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (2)