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.


Script qr code

Explorer ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Can somebody help me with a script that find url codes and change it to a QR code with a object style named test.

 

kind regards,

Patrick

TOPICS
Scripting

Views

257

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 , Feb 12, 2021 Feb 12, 2021
Try this snippet :  ////////////////////////////////////////////////////////////////////////////////////////////////////// app.findGrepPreferences = NothingEnum.nothing; app.changeGrepPreferences = NothingEnum.nothing; app.findGrepPreferences.findWhat = "((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+ \\/.\\w_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[\\w]*))?)"; var allFound = app.documents[0].findGrep(); for(var i = 0; i < al...

Likes

Translate

Translate
Adobe Community Professional ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

Try this below snippet for add QR code for URL:

//////////////////////////////////////////////////////////////////////////////////////////////////////
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "(ftp:\/\/|www\.|https?:\/\/){1}[a-zA-Z0-9u00a1-\uffff0-]{2,}\.[a-zA-Z0-9u00a1-\uffff0-]{2,}(\S*)";
var allFound = app.documents[0].findGrep();
for(var i = 0; i < allFound.length; i){
    var urlLink = allFound[0].texts[0].contents.toString();
    var qrCodeObject = allFound[i].insertionPoints[-1].rectangles.add({geometricBounds:[0, 0, 10, 10]});
    qrCodeObject.createHyperlinkQRCode(urlLink);
    qrCodeObject.label = "QR-URL";
    allFound[0].texts[0].contents = "";
    app.documents[0].recompose();
    allFound = app.documents[0].findGrep();
    }
//////////////////////////////////////////////////////////////////////////////////////////////////////

 

After placement of all QR code if you want to change size of those QR codes find them with their script label & can change the geometric bounds or apply any object style.

 

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
Explorer ,
Feb 11, 2021 Feb 11, 2021

Copy link to clipboard

Copied

When i have a URL like www.bcm.nl it's working fine. When i have http://www.bcm.nl he makes a QR code of http://www.bcm and the .nl he dont take it.

so i get (QR code).nl

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 ,
Feb 12, 2021 Feb 12, 2021

Copy link to clipboard

Copied

Try this snippet : 

 

//////////////////////////////////////////////////////////////////////////////////////////////////////
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.findWhat = "((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+ \\/.\\w_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[\\w]*))?)";
var allFound = app.documents[0].findGrep();
for(var i = 0; i < allFound.length ; i){
    var urlLink = allFound[i].texts[0].contents.toString();
    var qrCodeObject = allFound[i].insertionPoints[-1].rectangles.add({geometricBounds:[0, 0, 10, 10]});
    qrCodeObject.createHyperlinkQRCode(urlLink);
    qrCodeObject.label = "QR-URL";
    allFound[i].texts[0].contents = "";
    app.documents[0].recompose();
    allFound = app.documents[0].findGrep();
    }
//////////////////////////////////////////////////////////////////////////////////////////////////////

 

[Code Edited]

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

Copy link to clipboard

Copied

Thank you for the code. I am trying to use the snippet, but haven't figured out the best way to do so.

I copied and pasted it into a plain text file and save it as a JSX and put it into my InDesign scripts folder. But when I attempt to run the script, nothing happens.

 

What am I missing?

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 ,
Nov 04, 2021 Nov 04, 2021

Copy link to clipboard

Copied

You are doing correct to run the script. But your document might have something extra of may be URL might not be matching. Can you share those URL that you are trying to do on?

Or may be if you can share InDesign document.

 

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

Copy link to clipboard

Copied

I can't share the InDesign document or that specific URL, but it happns with other URLS as well. Here's one for which I got the following error: 

https://www.knitswag.com

 

Screen Shot 2021-11-05 at 9.10.33 AM.png

I tried the following before running the script:

  • Selecting nothing
  • Selecting the frame containing the URL
  • Selecting the entire URL

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 ,
Nov 06, 2021 Nov 06, 2021

Copy link to clipboard

Copied

LATEST

Did you make sure after adding all those qr code your parent stroy frame will not run into overflow?

Try to add few frames extra & link to it so that while inserting QR code main frame should not go into overflow.

 

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