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

Match url and change in qr code

Contributor ,
Oct 15, 2020 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

1.0K

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

Advocate , Oct 16, 2020 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

...

Votes

Translate

Translate
Advocate ,
Oct 16, 2020 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

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
Contributor ,
Oct 18, 2020 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

 

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
New Here ,
May 30, 2023 May 30, 2023

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? 

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 ,
May 30, 2023 May 30, 2023

Copy link to clipboard

Copied

This is NOT an InDesign issue. You need to learn how 301 redirects work and use that.

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
New Here ,
May 30, 2023 May 30, 2023

Copy link to clipboard

Copied

Sorry I didn't get the point. Could you please help me understanding where doing the fix? 

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 ,
May 30, 2023 May 30, 2023

Copy link to clipboard

Copied

LATEST

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. 

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
New Here ,
Dec 16, 2020 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.

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
Advocate ,
Dec 23, 2020 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

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