Olivier Posted June 14, 2020 Share Posted June 14, 2020 Hi all, I have a project with an Image Collection with about 600 files on different formats (12345.tif, 23456.eps, 34567b.png...). The images are “named“ with a reference/sku (12345, 23456, 34567...). In the project, the user will type a reference in a text field, and I have to build the page with the correct image based on the text field. I can't build a Switch ruel as the images names are not constant (PNG/GIF/TIF... and there might be some suffixes like 34567b. So what may I do ? I will also have to add some new images along the year corresponding to new references and I don't want to edit a long long rule Any idea ? Best regards Olivier MarcomCentral Acrobat X FusionPro 10.1 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 15, 2020 Share Posted June 15, 2020 I can think of two ways to do this. First way: Add all the graphics as named resources in the Resources dialog. If you make each resource name match a value in the data, then you don't need any JavaScript at all. Just go into the Field editor (from the menu in Acrobat, FusionPro -> Data Definition -> Edit Fields, select your field, click Edit), and change the field's type to Graphic. Then you can select the field directly as the variable name in the Frame Properties palette. Second way: Write the rule to try different graphic filename extensions, like so: var baseName = Field("YourFieldName"); var extensions = [".tif", "gif", ".png", ".jpg"]; for (var i in extensions) { var pic = CreateResource(baseName + extensions[i], "graphic", true); if (pic.exists) return pic; } Print("Graphic " + baseName + " not found."); return NullResource(); The first way is a bit more setup but will compose more quickly and be more reliable. Quote Link to comment Share on other sites More sharing options...
Olivier Posted June 17, 2020 Author Share Posted June 17, 2020 Hi, Thank you Dan I will try the 2 options. Best regards, Olivier Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.