PDA

View Full Version : Set FP Expression Image in Loop


ThomasLewis
December 17th, 2013, 06:13 PM
I have the following snippet of code in a loop in OnRecordStart where I am trying to populate many sequentially named graphic frames with FusionPro Expression images.

The problem I am running into is the .SetGraphic parameter must be a resource type "graphic". How would I set an "FP Expression Image" resource so I can do this in the loop?

var myPI = CreateResource(fpx_array[x], "FP Expression Image");
myPI.AddData(UntaggedDataField("first"));

FindGraphicFrame("fpx-" + x).SetGraphic(myPI);

Dan Korn
December 18th, 2013, 09:08 AM
Try this:
FindGraphicFrame("fpx-" + x).SetGraphic(myPI.content);

ThomasLewis
December 18th, 2013, 09:41 AM
That validates which is a nice step forward but it errors in the composition log.

Composing record #1, input record 1
Graphic is not found or is not processed properly: <pimage file=ArtGallery_85009_24fpx.fpx><data>Thomas</data></pimage>.
Check for file existence and that it is of the proper format.
No value associated to graphic copyhole <> in record 1.

The "ArtGallery_85009_24fpx.fpx" file, along with the others, is in the same directory as the template file. I also tried bringing the files into FusionPro's Resources. In the error log it lists the entire path when I do that, so I'm sure it's finding the files okay. It must be the "of the proper format" part it's having an issue with.

Dan Korn
December 18th, 2013, 10:11 AM
Ah, okay, sorry.

I don't think there's a way to do that, at least not directly. The FusionProGraphicFrame.SetGraphic and FusionPro.Composition.AddGraphicVariable functions really do take only "regular" graphics, not personalized images.

How many FP Expression images are you trying to use in a record? I haven't seen a many jobs with more than two or three. You might be able to rework the job to use Imposition instead.

Or, you could bring in the images as inline graphics in text frames, like so:
FindTextFrame("fpx-" + x).content = myPI.content;You can also set the width and/or height, just like with any other inline graphics; something like this:
FindTextFrame("fpx-" + x).content = ReplaceSubstring(myPI.content, "<pimage ", "<pimage height=7200 ");

ThomasLewis
December 18th, 2013, 10:23 AM
It's a 200+ record, 26 page document with 24 expression images throughout. I was trying to avoid having to make a graphic rule for each one.

I'll try your other suggestions and see if I can get them going. Replacing the tag with the size is a neat idea. Thank you for your help.

ThomasLewis
December 18th, 2013, 10:34 AM
FindTextFrame("fpx-" + x).content = ReplaceSubstring(myPI.content, "<pimage ", "<pimage height=7200 ");

This is working great, thanks again!