Delete all kinds of empty frames anchored within a table!!

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Delete all kinds of empty frames anchored within a table!!

Viewing 2 reply threads
  • Author
    Posts
    • #85312
      Masood Ahmad
      Participant

      Hi, Can anyone please create a JavaScript that can delete all kinds of empty frames from a document.

      These empty frames can be:
      1. N number of frames in a document
      2. Text frames
      3. Graphic frames (rectangle, oval, polygon etc)
      4. Anchor within text or within table.

      For your reference, the file is uploaded here: https://www.hightail.com/download/cUJVck8zQVMwMEZ1a3NUQw

      Except the one that has a Text-Wrap applied to it.

      Thanks in advance.

    • #85383

      Hi Masood,

      please try the following:

      var curDoc = app.documents[0];
      var allFrames = curDoc.allPageItems;
      
      for (var i = allFrames.length-1; i >= 0; i--) {
        var curFrame = allFrames[i];
        var curType = curFrame.constructor.name;
      	var wrap = curFrame.textWrapPreferences.textWrapMode;
        if (curType == "TextFrame" && curFrame.contents == "" && wrap == TextWrapModes.NONE) {
            curFrame.remove();
        }
        else if (curType == "Rectangle" || curType == "Polygon" || curType == "Oval") {
          if (!curFrame.graphics.length) {
            if (curFrame.fillColor.name == "None" && curFrame.strokeColor.name == "None" && wrap == TextWrapModes.NONE) {
              curFrame.remove();
            }
          }
        }
      }
      

      best
      Kai

    • #85387
      Masood Ahmad
      Participant

      Hi Kai Rübsamen,

      I tried your script on one simple file and it worked great. Million thanks for writing a code for me.

      Tomorrow I’ll check the script with my original document and will update you, if needed.

      Thanks once again.

      Masood :)

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>
Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo