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
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
...
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
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
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
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?
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
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:
I tried the following before running the script:
Copy link to clipboard
Copied
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