4 Replies Latest reply on Mar 14, 2016 10:47 AM by PlainMartin

    Script for applying object style and width to image frame after XML import?

    PlainMartin Level 1

      I'm importing some self-cooked XML into a long-form InDesign document. Applying paragraph and character styles using the "Map Tags to Styles" feature works as expected. Applying paragraph and character style variations using the aid namespace also works as it should. What I can't get to work is this:

      • For each imported image, assign the image frames an Object Style (e.g. "AnchoredImage")
      • Give the image a fixed width (e.g. 20mm).


      What I get instead is full-size, high-res images, and then I have to click through dozens of imported images and apply the required object style after each import. Here's the kind of XML I'm importing:



      <head1>Main head</head1>

      <head2>Subhead with an anchored image


         <img href="file:///Users/really/long/path/illustration.jpg" aid:ostyle="AnchoredImage" />



      <p aid:pstyle="BodyIntro">Introduction</p>

      <p>Rest of the text</p>


      As you see, I tried to apply an object style here, but it seems that other than "pstyle" and "cstyle", "ostyle" isn't a thing.


      I suppose the easiest solution is an InDesign script that will 1.) apply the "AnchoredImage" object style to every image frame and then 2.) resize all image frames to a fixed width. As the "AnchoredImage" object style sets "Auto-Fit" to on and "Content fitting" to "Fit Content Proportionally", I assume this would adjust height (which can vary) correctly in the second step.


      Would someone be so nice to provide such a script?