6 Replies Latest reply on Jun 8, 2016 1:07 AM by Trevorׅ

    Auto-size not refreshing after GREP

    McShaman Level 1

      I have a script where I have text blocks that are populated by data and then those text blocks are distributed vertically. However I have run into an issue where the text blocks are not auto-resizing before the distribution is performed.


      To replicate this issue:

      • Create a new document
      • Draw a text box
      • Enable auto-size on it (height only)
      • Put at least two lines of text in it

      Now run this script:

      var removeBlankParagraphs = function(p_item) {
        app.findGrepPreferences = NothingEnum.nothing;
        app.changeGrepPreferences = NothingEnum.nothing;
        app.findGrepPreferences.findWhat = '(?-m)\\r+$';
        app.changeGrepPreferences.changeTo = '';
      var document = app.activeDocument,
        template = document.pageItems[0],
        pageItems = [],
      for (var i = 0; i < 4; i++) {
        pageItem = template.duplicate();
      document.distribute(pageItems, DistributeOptions.VERTICAL_SPACE, undefined, true, 5, pageItems[0]);


      So what is meant to happen here is:

      • The text box is duplicated 4 times
      • The last paragraph is deleted on each duplicate
      • The duplicates are distributed by 5 ruler units

      However if you measure the distance between them they are not 5 ruler units. What seems to be happening here is that the text boxes are not auto-sizing right after the last paragraph is removed... It resizes after the distribute function.

      How do I fix this?