0

I have Indesign document with 366 qrcdoe and news source I find this script and edit it to GROUP any qrcode with specific object style (qrcode) and any text with specific paragraph style (مصدر الخبر) individually in entire document

var myDoc = app.activeDocument;
// Loop through each page in the document
for (var i = 0; i < myDoc.pages.length; i++) {
  var currentPage = myDoc.pages[i];
  // Find all the page items on the current page that have the object style named "qrcode"
  var qrcodes = currentPage.getElements({objectType: Oval, appliedObjectStyles: "qrcode"});
  // Find all the text frames on the current page that have the paragraph style named "مصدر الخبر"
  var newsSources = currentPage.getElements({objectType: TextFrame, appliedParagraphStyle: "مصدر الخبر"});
  // Loop through each QR code and group it with its associated news sources
  for (var j = 0; j < qrcodes.length; j++) {
    var currentQRCode = qrcodes[j];
    // Find all the news source text frames associated with the current QR code
    var associatedNewsSources = currentQRCode.associatedXMLElements.getElements({objectType: TextFrame, appliedParagraphStyle: "مصدر الخبر"});
    // If there are associated news sources, group them together
    if (associatedNewsSources.length > 0) {
      var currentGroup = currentPage.groups.add([currentQRCode].concat(associatedNewsSources));
      currentGroup.move(currentPage);
    }
  }
  // Loop through each news source text frame and group it with its associated QR codes
  for (var k = 0; k < newsSources.length; k++) {
    var currentNewsSource = newsSources[k];
    // Find all the QR codes associated with the current news source
    var associatedQRCodes = currentNewsSource.getElements({objectType: Oval, associatedXMLElements: "مصدر الخبر"});
    // If there are associated QR codes, group them together
    if (associatedQRCodes.length > 0) {
      var currentGroup = currentPage.groups.add([currentNewsSource].concat(associatedQRCodes));
      currentGroup.move(currentPage);
    }
  }
}

enter image description here

But when I Run Script I have this Problem

enter image description here

is there any help I well be appreciated

2
  • Oh my, somebody didnt understand what commenting code means.
    – joojaa
    Mar 31, 2023 at 3:44
  • @joojaa sorry my English very weak if you can help me I well be thanks
    – Hassan
    Mar 31, 2023 at 12:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.