Skip to main content
total copys73685545
Participant
February 9, 2024
Question

Automatic create multiple QR-codes in Indesign adding a new page for every code

  • February 9, 2024
  • 2 replies
  • 1137 views

I 've been asked to create a document with 10.000 pages. On every page I need to place a unique QR-code that refers to a unique url. I want to generate the QR-codes automaticly (based on a CSV-list or something else?) and would like automaticly add a page for every QR-code (with the data-merge-function in indesign?)

 

This topic has been closed for replies.

2 replies

rob day
Community Expert
Community Expert
February 9, 2024

Hi @total copys73685545 , You could script the creation of the document and pages, which might be easier than a data merge. This opens a text file on the desktop with each url as a line, and creates the pages and qCodes. You might have a problem creating a 10,000 page doc with a eps on each page—probably depends on your hardware. Something like this might work:

 

/* a text file on the desktop  named URLList.txt with the urls with returns, e.g.
www.adobe.com
www.instagram.com
www.goggle.com */

var qc = readFile(File(Folder.desktop + "/URLList.txt"))

app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;
var dn = "QCodes";

//tha page’s width and height
var pw = 6;
var ph = 6;

//make a new document
var currdate = new Date
var dp = makeDocPreset("Temp-" + currdate.getTime());
dp.properties = {facingPages:false, pageHeight:pw, pageWidth:ph, top:0, bottom:0, left:0, right:0}
var doc = app.documents.add(true, dp);
doc.name = "QCodes"
dp.remove();

//loop through the url list and add pages with the codes
var np, r;
for (var i = 0; i < qc.length; i++){
    np = doc.pages.add()
    r = np.rectangles.add({geometricBounds:[0, 0, ph, pw]})
    r.createHyperlinkQRCode(qc[i])
};   

app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE; 



/**
* Makes a new document preset 
* @ param preset name name 
* @ return the new preset 
*/
function makeDocPreset(n){
    if (app.documentPresets.itemByName(n).isValid) {
        return app.documentPresets.itemByName(n);
    } else {
        return app.documentPresets.add({name:n});
    }
}

/**
* Open a text file
* @ param The text file path 
* @ return the text’s paragraphs as an array 
* 
*/

function readFile(p) {
	var f = new File(p);
	f.open("r");  
	var x = f.read(); 
    var r = x.split("\n") 
	f.close();
	return r; 
}

Result

Robert at ID-Tasker
Legend
February 9, 2024

You need to create a placeholder - Rectangle on a page - InDesign will do the rest. 

 

Or are you asking for a step-by-step guidance? 

 

https://helpx.adobe.com/uk/indesign/using/data-merge.html