Velotypo Posted December 28, 2016 Share Posted December 28, 2016 Hi, I am trying to do a job where the pdf has 12 pages but I need to use one of them based on a data field. I was planning on using an OnJobStart call back rule and use an if statement to pick which page to use based on a data field. The data looks something like this. DivisionName FirstName LastName Gender Style Size etc. Corporate Joe Smith Male Long XL Central Bob Murphy Male Short L The 12 pages in the PDF are named by the Division. There are a number of variable text frames on each page. Just need to pull the page to match the division but the JavaScript syntax just does not make sense to me!! Thanks for any help! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 29, 2016 Share Posted December 29, 2016 Set all 12 of the pages to Unused in the Page Usage dialog. Then in OnRecordStart you can just do this: FusionPro.Composition.SetBodyPageUsage(Field("Division"), true); Quote Link to comment Share on other sites More sharing options...
Velotypo Posted December 29, 2016 Author Share Posted December 29, 2016 Thanks for the reply. I input the the code you suggested but I get a Fatal Error message saying FP must Abort Error No. 1096. In the msg file the first line is. "OnJobStart, line 1: Error: In Field(), no data source defined or data could not be loaded" I thought maybe the Field name was the problem and made sure that (Field("Division") matched the header line in my database which is "DIVISION NAME" but I got the same result. Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 29, 2016 Share Posted December 29, 2016 In the msg file the first line is. "OnJobStart, line 1: Error: In Field(), no data source defined or data could not be loaded" No, not OnJobStart. The call to set the page usage has to go into OnRecordStart, like I said: Set all 12 of the pages to Unused in the Page Usage dialog. Then in OnRecordStart you can just do this: FusionPro.Composition.SetBodyPageUsage(Field("Division"), true); Quote Link to comment Share on other sites More sharing options...
Velotypo Posted December 29, 2016 Author Share Posted December 29, 2016 Opps, Did not read it thoroughly! Using that code in the correct OnRecordStart seems to work just fine. I composed one and everything looks good. But I am still getting an error message. OnRecordStart, line 1: Error: In SetBodyPageUsage(), no page name or number specified. It does not seem to effect my job, what does this error mean? Thanks for your help!!!! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 29, 2016 Share Posted December 29, 2016 Using that code in the correct OnRecordStart seems to work just fine. I composed one and everything looks good. But I am still getting an error message. OnRecordStart, line 1: Error: In SetBodyPageUsage(), no page name or number specified. It does not seem to effect my job, what does this error mean? For what record do you get that error? And what is the value of the "Division" field in that record? You might want to add this to the rule: Print('Division is "' + Field("Division") + '"'); Then you should be able to see what the data field value is which corresponds to the error message in the log file. Quote Link to comment Share on other sites More sharing options...
Velotypo Posted December 29, 2016 Author Share Posted December 29, 2016 I think I figured it out. There is an odd number of records and I am imposing the 8.5x11 pages 2up on 17x11 and the error is at the very end where it is looking for one more record to fill out the imposition. Thanks again! Quote Link to comment Share on other sites More sharing options...
Velotypo Posted December 29, 2016 Author Share Posted December 29, 2016 The Problem with the error actually ended up being a stray character on the last line of the database in one of the fields. Uhgggg!!! Thanks Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 30, 2016 Share Posted December 30, 2016 The Problem with the error actually ended up being a stray character on the last line of the database in one of the fields. Uhgggg!!! Well, you could trim off extra spaces: FusionPro.Composition.SetBodyPageUsage(Trim(Field("Division")), true); But that might not catch all the problems with the data. If you want to be more robust about error handling, you could add another Unused Body page called "Exception" with some text such as "No page found for Division «Division»" in big red text in a frame on it, and change the OnRecordStart rule to something like this: try { FusionPro.Composition.SetBodyPageUsage(Trim(Field("Division")), true); } catch (e) { FusionPro.Composition.SetBodyPageUsage("Exception", true); Print('ERROR: No page found for Division "' + Field("Division") + '"'); } 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.