Fields Containing Multiple Images
Fields may contain references to multiple images, each separated by a carriage return. For example:
image1.png
image2.png
image3.png
Here’s a simple post processing script that paginates these into the bounds of the formatting rule. The rule must have a graphic frame tagged with the field and a script label set to “icon” so it can be identified by the script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | -- get the bounds on the formatting rule; container_bounds = formattingrule:getbounds(); -- find the icon frame icon = formattingrule:getframe("icon"); index = 1; -- setimageindex applies a computed field command to get the nth image -- from the field, then updates the frame. Returns true if an image was placed. while icon:setimageindex(index) do index = index + 1 -- duplicate the icons at the same point in the hierarchy icon = icon:duplicate(); end -- delete the orphaned item icon:delete() -- no items were paginated so exit if index == 1 then return end -- get all the frames called "icon" named_frames = formattingrule:getframes("icon"); -- arrange the icons inside the original bounds of the formatting rule. formattingrule:arrange(named_frames); |
Multiple Fields Containing Images
When a formatting rule is paginating multiple records, and each has an image, the following code will duplicate the image relating to the first record and populate it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | icon = formattingrule:getframe("icon"); -- selection contains all records for the formatting rule sel = SELECTION.root(); -- first item is already paginated, so start at the 2nd for i=2,sel:size() do -- duplicate the frame. If the item is anchored it will be duplicated after. newf = icon:duplicate(); -- update the content of the frame with the selection item newf:updatecontent(sel:get(i)); end |