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

Qr code web hyperlink to hyperlink for interactive pdf.

Community Beginner ,
Aug 30, 2021 Aug 30, 2021

Copy link to clipboard

Copied

Hello,

I'm creating a catalog in indesign. It's finished and about 800 pages. I just got asked to make it interactive. We have qr codes included on almost all the pages. I would like to ask if somebody knows if its possible to script a action to create a hyperlink from the currently used qr code web hyperlink 

What legendary scripter can help me with this 🙂

Thanks in advance!

TOPICS
Scripting

Views

778

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 , Sep 01, 2021 Sep 01, 2021

Just Put a try catch block for exception handling, that will take of things.

//=======================================
addHyperlinkQRCode();
function addHyperlinkQRCode(){
    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++){
            try{
                if(myDoc.pages[i].pageItems[p].epss.length > 0){
                    var QRCode = getHyperlinkQRCode(myDoc.pages[i].pageItems[p].epss[0]);
       
...

Votes

Translate

Translate
Advocate ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

To add the hyperlink on QR code itself, so that while just onclick it should jump, you can give it a shot to below snippet :

//=======================================
addHyperlinkQRCode();
function addHyperlinkQRCode(){
    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){
                    myDoc.pages[i].pageItems[p].createHyperlinkQRCode(QRCode);
                    var src=myDoc.hyperlinkPageItemSources.add(myDoc.pages[i].pageItems[p]);
                    var dest = myDoc.hyperlinkURLDestinations.add(QRCode);
                    myDoc.hyperlinks.add(src, dest);
                    }
                }
            }
        }
    }
//=======================================
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
Community Beginner ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Hi Sunil!

Thanks for the snippet, but unfortunately it is not working. I'm getting an error.
See the attachment for the window error.

I hope this doesn't take to much time to find a fix for this!
Thanks alot for the effort!

Best 
Joeri

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 ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Just Put a try catch block for exception handling, that will take of things.

//=======================================
addHyperlinkQRCode();
function addHyperlinkQRCode(){
    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++){
            try{
                if(myDoc.pages[i].pageItems[p].epss.length > 0){
                    var QRCode = getHyperlinkQRCode(myDoc.pages[i].pageItems[p].epss[0]);
                    if(QRCode != null){
                        myDoc.pages[i].pageItems[p].createHyperlinkQRCode(QRCode);
                        var src=myDoc.hyperlinkPageItemSources.add(myDoc.pages[i].pageItems[p]);
                        var dest = myDoc.hyperlinkURLDestinations.add(QRCode);
                        myDoc.hyperlinks.add(src, dest);
                        }
                    }
                }
            catch(e){}
            }
        }
    }
//=======================================
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
Community Beginner ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

Thank you so much! It works like a charm!

Best
Joeri

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Thanks for the script. For QR-codes outside of test boxes it works fine. But when the QR-code stands inside an text field or an anchor object it doesn't work. Is there a solution for this? Thank you for your efforts. 

 

Best 

Julian

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

 

Changed pageItems to allPageItems per page. Didn't test; let me know if errors.

//=======================================
addHyperlinkQRCode();
function addHyperlinkQRCode(){
    var myDoc = app.documents[0];
    var apis;
    for(var i = 0; i < myDoc.pages.length; i++){
        apis = myDoc.pages[i].allPageItems;
        for(var p = 0; p < apis.length; p++){
            try{
                if(apis[p].epss.length > 0){
                    var QRCode = getHyperlinkQRCode(apis[p].epss[0]);
                    if(QRCode != null){
                        apis[p].createHyperlinkQRCode(QRCode);
                        var src=myDoc.hyperlinkPageItemSources.add(apis[p]);
                        var dest = myDoc.hyperlinkURLDestinations.add(QRCode);
                        myDoc.hyperlinks.add(src, dest);
                        }
                    }
                }
            catch(e){}
            }
        }
    }
//=======================================
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;
        }
    }

 

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

Tested it, but it works like the script before. Outside of textboxes it works fine, but in textboxes it won't work. Is there any other option? Thank you very much for your help.

 

Best

Julian

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 04, 2022 Dec 04, 2022

Copy link to clipboard

Copied

LATEST

Sorry for late response.

Can you show some screenshot of your document will make things clear.

 

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