LyndaEngelage Posted June 9, 2015 Share Posted June 9, 2015 I am very new to FusionPro and have a question. I have 62 different pdfs with each having 2 pages. I have a graphic frame on page 1 and 2. How do I get FP to use the 2nd page on page 2 of the variable graphic frame. I'm using the "Insert Picture" rule for both graphics frames. I do not know JavaScript. Quote Link to comment Share on other sites More sharing options...
step Posted June 9, 2015 Share Posted June 9, 2015 1. Name your graphic frames by the page number that you'd like to display in them (i.e. frame name: "1" will display page 1, frame name: "2" will display page 2). 2. Open your list of rules 3. Double click "Insert Picture Rule" and click "Convert to JavaScript" 4. Check the check box at the top beside "Re-evaluate this rule for every graphic frame" 5. Edit the code to below. You only need to add the line I've added (highlighted in red) the rest of the code should match yours and I've only included it for context. temp = ''; var_extension = ''; has_extension = ''; if (Var3 == "") Var3 = Var3; else { if (FusionPro.isMac) Var3 = Var3 + ":"; else Var3 = Var3 + "\\"; } for (i=0; i<Field(Var1).length; i++) { temp = Mid(Field(Var1), Field(Var1).length-i,1); var_extension = temp + var_extension; var_extension = ToLower(var_extension); if(var_extension == ".png" || var_extension == ".pdf" || var_extension == ".gif" || var_extension == ".eps" || var_extension == ".tif" || var_extension == ".tiff" || var_extension == ".jpg" || var_extension == ".jpeg") { has_extension = "true"; i=Field(Var1).length; } else has_extension = "false"; } if(has_extension == "true") Pic = CreateResource(Var3 + Field(Var1), "graphic", true); else { if(Var2 == ".jpg") { Pic = CreateResource(Var3 + Field(Var1) + ".jpeg", "graphic", true); if (Pic.exists) Pic = Pic; else Pic = CreateResource(Var3 + Field(Var1) + ".jpg", "graphic", true); } if(Var2 == ".tif") { Pic = CreateResource(Var3 + Field(Var1) + ".tif", "graphic", true); if (Pic.exists) Pic = Pic; else Pic = CreateResource(Var3 + Field(Var1) + ".tiff", "graphic", true); } if(Var2 == ".png" || Var2 == ".pdf" || Var2 == ".eps" || Var2 == ".gif") { Pic = CreateResource(Var3 + Field(Var1) + Var2, "graphic", true); } } if (Pic.exists) { [color="Red"]Pic.pagenumber = FusionPro.Composition.CurrentFlow.name;[/color] return Pic; } else { return CreateResource(Var3 + Var4, "graphic", true); } Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted June 9, 2015 Author Share Posted June 9, 2015 Thank you for the quick reply but I'm not sure if I need all this code. I'm using InsertPicture based on a database field and my images are only in pdf format. My rule appears with a lot less code. Please see attachment if you can read it. Quote Link to comment Share on other sites More sharing options...
step Posted June 9, 2015 Share Posted June 9, 2015 Okay. When I created an Insert Picture Rule that was the code that was generated for me. You don't need it – it's basically there to handle other file types and whatnot. Anyway, Insert the code I previously mentioned (in red) above the "return Pic" line in your code, select that check box at the top of the rule editor and you should be all good: Pic = CreateResource(Field("Image Code") + ".pdf", "graphic", true); if (Pic.exists){ [color="Red"]Pic.pagenumber = FusionPro.Composition.CurrentFlow.name;[/color] return Pic; } else { return Resource("Cart 4247 PM8945.pdf"); } You'll need to double check to make sure I wrote your default image name ("Cart 4247 PM8945.pdf") correctly. I had a pretty difficult time reading it from your screen grab. Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted June 9, 2015 Author Share Posted June 9, 2015 Now when I preview, I'm getting the default image on every page and only the first page of that default page. Please see attachment for the revised rule. Quote Link to comment Share on other sites More sharing options...
step Posted June 9, 2015 Share Posted June 9, 2015 You didn't attach anything. But that's okay, it would be much easier on my eyes if you'd copy and paste the rules. Anyway, basically what the rule is saying is this: Create a resource called "[The value of the "Image code" field].pdf". Then check to see if that resource exists in a place that FP can find it. If it doesn't, return the default image. If it does, set the page number to the name of the frame it's returning the graphic for. The fact that you're always getting the default graphic leads me to believe that FP can't find the graphic you've told it to look for. Keep in mind that as I said above, you're adding ".pdf" to the end of the field value so if your field value is "image.pdf" then FP is searching for a resource called "image.pdf.pdf." You'd either need to remove the ".pdf" from the code or from the data itself. I originally did not code for the default image to return the second page. To do that try this: Pic = CreateResource(Field("Image Code") + ".pdf", "graphic", true); var result = (Pic.exists) ? Pic : Resource("Cart 4247 PM8945.pdf"); result.pagenumber = FusionPro.Composition.CurrentFlow.name; return result; If you have the extension included in your field value do this: Pic = CreateResource(Field("Image Code"), "graphic", true); var result = (Pic.exists) ? Pic : Resource("Cart 4247 PM8945.pdf"); result.pagenumber = FusionPro.Composition.CurrentFlow.name; return result; Quote Link to comment Share on other sites More sharing options...
LyndaEngelage Posted June 9, 2015 Author Share Posted June 9, 2015 That did the trick! Thank you very much for your expertise and for helping me on this. It works perfectly. 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.