Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

79

Likes

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

Adobe Community Professional , 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]); ...

Likes

Translate

Translate
Adobe Community Professional ,
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

Likes

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

Likes

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
Adobe Community Professional ,
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

Likes

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

LATEST

Thank you so much! It works like a charm!

Best
Joeri

Likes

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