Jump to content

adding page count to the output file name


Sean

Recommended Posts

I have a variable page book (between 50-70 pages) that I would like to add a page count to the output file name. So far I have been able to add 3 fields to the file name: ID, first name and last name. When I try to add a field for page count and compose the book, the output file name looks like this: "0_1234_FNameLname.pdf". The page count always comes up as being "0". I have the following rule running at record start (-minus the page count field):

 

if (FieldChanged("ID"))
FusionPro.Composition.OpenNewOutputFile(Field("ID") + "_" + (Field("First Name") + (Field("Last Name") + "." + FusionPro.Composition.outputFormatExtension)));

 

This works fine but need to add page count to the beginning of file name. I do have the callback rule for "onpagecount" running as well. Please let me know if any other information is needed. Any help would be greatly appreciated.

 

Thanks, Sean

Link to comment
Share on other sites

You mean the page count of the file you're opening, in OnRecordStart, before you have even told FusionPro whether to compose that record (and any subsequent records which may go into that file) and which body pages to set to used and unused, let alone what the content is that may affect how many Overflow pages will be inserted? The problem is that FusionPro doesn't have any way of knowing what the output page count for the new output file is going to be, because it hasn't composed anything that goes into that file yet.

 

The only callback that knows how many pages have been output for the current record is OnPagesInserted, because, as its name suggests, that gets called after the output page count for the record has been determined (taking into account inserted pages from overflows). Unfortunately, though, that's too late to change the output file name.

 

So, the short answer is No, there isn't any way to add the page count to the file name. Why do you want to do that anyway?

 

Having said all that, there may be a way to make this work, depending on the job. If your job is not using Overflow pages, then you should be able to calculate how many pages will be output for each record, since the only thing that would affect that is any calls you're making to FusionPro.Composition.SetBodyPageUsage. But the other problem I think you'll have is knowing how many records will be put into the new output file that you're opening. To figure that out, you need to read ahead in the data file, and there are two ways to do that: (1) the easier way, to read the file with ExternalDataFileEx, or (2) the harder way, to change the OnRecordStart logic to accumulate all the records of data into a global JavaScript object until you get to a new ID, then open your output file and repeat the record for each record accumulated, injecting the accumulated data as appropriate for each repeat. The tricky part about the second way is what to do at the very end of the data.

 

Depending on why you're trying to get the page count, you might also consider turning on the XML log file for the job. You can either call FusionPro.Composition.CreateXMLLogFile(), optionally with the file path and name, from OnJobStart, or, if you're using FP Server, you can set the CFG entry XMLLogFile. The XML log will list each output file created and how many records and pages are in each.

Link to comment
Share on other sites

You mean the page count of the file you're opening, in OnRecordStart, before you have even told FusionPro whether to compose that record (and any subsequent records which may go into that file) and which body pages to set to used and unused, let alone what the content is that may affect how many Overflow pages will be inserted? The problem is that FusionPro doesn't have any way of knowing what the output page count for the new output file is going to be, because it hasn't composed anything that goes into that file yet.

 

The only callback that knows how many pages have been output for the current record is OnPagesInserted, because, as its name suggests, that gets called after the output page count for the record has been determined (taking into account inserted pages from overflows). Unfortunately, though, that's too late to change the output file name.

 

So, the short answer is No, there isn't any way to add the page count to the file name. Why do you want to do that anyway?

 

Having said all that, there may be a way to make this work, depending on the job. If your job is not using Overflow pages, then you should be able to calculate how many pages will be output for each record, since the only thing that would affect that is any calls you're making to FusionPro.Composition.SetBodyPageUsage. But the other problem I think you'll have is knowing how many records will be put into the new output file that you're opening. To figure that out, you need to read ahead in the data file, and there are two ways to do that: (1) the easier way, to read the file with ExternalDataFileEx, or (2) the harder way, to change the OnRecordStart logic to accumulate all the records of data into a global JavaScript object until you get to a new ID, then open your output file and repeat the record for each record accumulated, injecting the accumulated data as appropriate for each repeat. The tricky part about the second way is what to do at the very end of the data.

 

Depending on why you're trying to get the page count, you might also consider turning on the XML log file for the job. You can either call FusionPro.Composition.CreateXMLLogFile(), optionally with the file path and name, from OnJobStart, or, if you're using FP Server, you can set the CFG entry XMLLogFile. The XML log will list each output file created and how many records and pages are in each.

 

Dan, thank you very much for your help on this. It is much appreciated. The information that you have provided will help me explain as to why adding the page count to the file name is not currently possible.

 

The project will be a perfect bound book. We are looking for a way to run all the books with similar page counts to make it easier on our bindery department to put the books together.

 

The book does not use overflow pages. We are only using the FusionPro.Composition.SetBodyPageUsage to turn pages on and off depending on the data that is given to us. Unfortunately we do not know how many records will be received on a weekly basis. Right now, we are looking at 75-200 books a week.

Link to comment
Share on other sites

This is not a FusionPro solution, but we have a few projects that we gang or run together by page count as well.

 

What we do is compose the PDF files normally - into a specific folder. Then we use a utility called "PDFInfoGUI" (I think its a free tool - check google). You select the folder with all the PDF's and it will display a detail listing that includes all kinds of information about the files including page count.

 

We then sort the list by page count and select and drag the files in batches into our print que or hot folders.

 

Hope that helps.

pageCounts.JPG.d0b5ba280ea5b5b0eb17e2ec48dcad3f.JPG

Link to comment
Share on other sites

What we do is compose the PDF files normally - into a specific folder. Then we use a utility called "PDFInfoGUI" (I think its a free tool - check google). You select the folder with all the PDF's and it will display a detail listing that includes all kinds of information about the files including page count.

 

We then sort the list by page count and select and drag the files in batches into our print que or hot folders.

Sure, that will work, although it still requires a human to manually select and drag things. Creating the XML log file and parsing it would be a more automatable process.

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