Jump to content

1200 resources


Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...