Match url and change in qr code

Participant ,
Oct 15, 2020

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?

 

Screen Shot 2020-10-15 at 2.18.40 pm.png

 

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

TOPICS
Scripting

Views

137

Likes

Translate

Translate

Report

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

1 Correct Answer

Adobe Community Professional , Oct 16, 2020
Sunil Yadav Adobe Community Professional , Oct 16, 2020
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...

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Oct 16, 2020

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
Oct 18, 2020

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

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Dec 16, 2020

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Dec 23, 2020

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

Likes

Translate

Translate

Report

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