Jump to content

Composing with Specific Page using Data Field


Velotypo

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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!!!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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") + '"');
}

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...