aaronsupremeworks.com Posted October 24, 2008 Share Posted October 24, 2008 I ahev 1200 images that i want to swapin and out, is there a fst rule I can use instead ol manually linking all of the resources in the rules editor??? Something like: switch (Field("Image").toLowerCase()) { case "NBD2_ 1".toLowerCase(): return Resource(Field"Image"+".eps"); Thanks Aaron Link to comment Share on other sites More sharing options...
a-c Posted October 24, 2008 Share Posted October 24, 2008 You could do something like this: image_path = 'c:\\images\\'; Pic = CreateResource(image_path + Field("IMAGE"), "graphic", true); return Pic; Just set your path to the location of your images and put the add a field to your data with the file names. Link to comment Share on other sites More sharing options...
Dan Korn Posted October 24, 2008 Share Posted October 24, 2008 switch (Field("Image").toLowerCase()) { case "NBD2_ 1".toLowerCase(): return Resource(Field"Image"+".eps"); If you use the CreateResource function, you can access graphics by their file names, without having to add named Graphic resources. You should be able to just return the resource based on the field name. No switch statement should be necessary: return CreateResource(Field("Image")+".eps"); Note that if the files are not in the same location as your template PDF or input files, you will need to specify the full path, either in the rule as in a-c's post above, or in the "Search Path" box on the Advanced tab of the Composition Settings dialog. The only thing the above one-liner won't do is handle the case where the graphic isn't found. If you want to do that, you can add some extra logic, like so: var name = Field("Image") + ".eps"; var res = CreateResource(name, "graphic", true); if (res.exists) return res; Print("Unable to find resource " + name); return NullResource(); // Or return a default graphic Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.