Copy link to clipboard
Copied
Hi,
I need to collect the existing QR code's URL and match partially, then need to change the QR code. Could you please guide on this?
var pgItem= app.activeDocument.pageItems;
for(var g=0; g<pgItem.length; g++){
var epsItem = pgItem[g].epss;
if(epsItem){
//edit QR code
//Copy
//match with new qr code
//replace
}
}
Thanks,
Selva
Try this code sample:
//=======================================
editQRCode();
function editQRCode(){
var myDoc = app.documents[0];
for(var i = 0; i < myDoc.pages.length; i++){
for(var p = 0; p < myDoc.pages[i].pageItems.length; p++){
if(myDoc.pages[i].pageItems[p].epss.length > 0){
var QRCode = getHyperlinkQRCode(myDoc.pages[i].pageItems[p].epss[0]);
if(QRCode != null){
// Here you can find replace or match whatever you want
Copy link to clipboard
Copied
Try this code sample:
//=======================================
editQRCode();
function editQRCode(){
var myDoc = app.documents[0];
for(var i = 0; i < myDoc.pages.length; i++){
for(var p = 0; p < myDoc.pages[i].pageItems.length; p++){
if(myDoc.pages[i].pageItems[p].epss.length > 0){
var QRCode = getHyperlinkQRCode(myDoc.pages[i].pageItems[p].epss[0]);
if(QRCode != null){
// Here you can find replace or match whatever you want to do with the link
QRCode = QRCode.replace("www.indesignjs.de ","www.google.com ");
// Here you create hyperlink QR code again, so it will be changed as well
myDoc.pages[i].pageItems[p].createHyperlinkQRCode(QRCode);
}
}
}
}
}
//=======================================
function getHyperlinkQRCode(QRCodeObject){
try{
var idmsFile = File (Folder.temp+"/~QR.idms");
QRCodeObject.exportFile(ExportFormat.INDESIGN_SNIPPET, idmsFile);
idmsFile.encoding = "UTF-8";
idmsFile.open("r");
var allData = new XML (idmsFile.read());
idmsFile.close();
idmsFile.remove();
var qrcode = allData..HyperlinkQRCode.@UrlLink;
if(qrcode.length() == 1) {
return qrcode.toString();
}
else{
null;
}
}
catch(e){
return null;
}
}
//=======================================
Best
Sunil
Copy link to clipboard
Copied
Hi Sunil,
This is a really nice approach to whichever we use to a different method for 'when we can't approach straight forward to the object'.
Thanks for the timely help.
Regards,
Selva
Copy link to clipboard
Copied
Hi,
I have the same problem. I already printed a tons of stuf with the qrCode made by using Express and now, due a problem with the server that doesn't recognize the url with the www. I need to change the link without changing the picture. Wher and how I can put the code you shared?
Copy link to clipboard
Copied
This is NOT an InDesign issue. You need to learn how 301 redirects work and use that.
Copy link to clipboard
Copied
Sorry I didn't get the point. Could you please help me understanding where doing the fix?
Copy link to clipboard
Copied
You need to redirect the www to the URL without it. That has to be done at the server level. There is NOTHING you can do in InDesign. Again, learn how to create a 301 redirect. This will depend on where the domain is registered. Some registrars have a simple check box for it.
Copy link to clipboard
Copied
Sorry, Where do I have to paste this code?
I am not so familiar with Indesign but I have this problem: the QR-code is already printed a thousand times, but I have to change the hyperlink behind. When I change in INdesign, the image changes also but I have only to change the hyperlink. How do I have to do that? Please help 😄 What is this development-code above? Do I have to place it somewhere? Thanks.
Copy link to clipboard
Copied
QR code is something that will those values. So definitely when you change the text behind this QR code, then QR code image will automatically gets change.
Sunil