DataMerge for shapes in Indesign

Learn / Forums / General InDesign Topics / DataMerge for shapes in Indesign

Viewing 7 reply threads
  • Author
    Posts
    • #76242
      Mohad D
      Member

      Hi Ppl, I’m new to In-design and trying to accomplish the following.

      I want to create a text box in a particular height and width while using the data merge feature. For example this is the data source :

      Name Country Size
      John US 20cm

      When I use this data source, it should fill in the above detail on the placeholder and create a box with size 20cm with the country name on it. how do i do this?

    • #76244
      Masood Ahmad
      Participant
    • #76246
      Loic Aigon
      Member

      Hi Mohad,

      Nor Datamerge, nor XML import will let you rearrange frame dimensions on the fly. It’s only a matter of Scripting here (given that you want to set a specific dimension. Otherwise frame options can help).

    • #76304
      Mohad D
      Member

      can someone help me with the script if i give the dimensions ?

    • #76323
      Eugene Tyson
      Member

      The Text Frame can autosize on importation of the data merge, but you can’t dictate the size.

      https://creativepro.com/keeping-long-fields-text-line-data-merge.php

      Best to find the longest size, set the font size to fit this at the required size. Then use the data merge feature.

    • #76374
      Mohad D
      Member

      Thanks guys..will try it out and keep you posted

    • #76391
      Loic Aigon
      Member

      Try this :

      var fn = function() {
      var doc, fgp = app.findGrepPreferences.properties,
      found, n, errors = 0, hu, vu;

      if ( !app.documents.length) return;

      doc = app.activeDocument;

      hu = doc.viewPreferences.horizontalMeasurementUnits;
      vu = doc.viewPreferences.verticalMeasurementUnits;

      doc.viewPreferences.horizontalMeasurementUnits =
      doc.viewPreferences.verticalMeasurementUnits =
      MeasurementUnits.POINTS;

      app.findGrepPreferences = null;

      app.findGrepPreferences.findWhat = “\\d+cm”;

      found = doc.findGrep();
      n = found.length;

      while ( n– ) {
      !doResize ( found[n] ) && errors++;
      }

      app.findGrepPreferences.properties = fgp;

      doc.viewPreferences.horizontalMeasurementUnits = hu;
      doc.viewPreferences.verticalMeasurementUnits = vu;

      alert( errors? errors+” errors occured on “+found.length+” occurences.” : “Everything was fine.” );
      }

      var doResize = function(text) {
      const ap = AnchorPoint.TOP_LEFT_ANCHOR,
      cs = CoordinateSpaces.INNER_COORDINATES,
      rm = ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH;
      var ptf, uv, w, props;

      if ( !text.parentTextFrames.length
      || !text.parentTextFrames[0].isValid
      || !/.+cm$/i.test(text.contents) ) return false;

      uv = new UnitValue ( text.contents.slice (0, -2), “cm” ).as(“pt”);
      ptf = text.parentTextFrames[0];
      props = getPageItemProperties ( ptf );
      ptf.resize ( cs,ap, rm, [uv, props.height] );
      return true;
      }

      var getPageItemProperties = function(pi) {
      var points = pi.paths[0].entirePath,
      n = points.length, i = 0,
      dummy, bounds, w, h;
      const cs = CoordinateSpaces.INNER_COORDINATES;
      var newPoints = [];

      while ( i < n ) {

      newPoints [ i ] = pi.resolve ( points[i], cs )[0];
      i++;
      }

      dummy = app.activeDocument.polygons.add();
      dummy.paths[0].entirePath = newPoints;
      bounds = dummy.geometricBounds;
      w = Math.round ( Math.abs ( bounds[3]-bounds[1])*1000)/1000;
      h = Math.round ( Math.abs ( bounds[2]-bounds[0])*1000)/1000;
      dummy.remove();

      return {width:w, height:h};
      };

      fn();

      Loic
      https://www.ozalto.com

    • #76682
      Colin Flashman
      Participant

      You could do this if you were using the chartwell bars font AND the auto-resize as Eugene suggests in his post.

      You would have to change the width of the chartwell bar font using the character scaling.

      See this post https://creativepro.com/chartwell-bars-scalable-data-merge-shapes.php to get an idea of what i’m talking about.

      Catch is, chartwell isn’t free – US$139 last time i checked.

Viewing 7 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