Jump to content

Output to multiple files AND keep pages together in pdf


JeremyT

Recommended Posts

I am working on a project where each record gets 17 output PDFs for production. The output PDFs are labeled by adding a name in the page usage dialog. This name is added to the individual PDF file name when output.

 

I'd also like a PDF for each record with all 17 pages in it for proofing to the customer. Each record needs its own PDF proof.

 

I am using OnNewOutputFile to output 17 pages in individual PDFs labeled with page name. I select each page to be unused in BodyPageUsage and then have OnNewOutputFile rule turn each page on when creating individual pdfs. "Ouput to Multiple files" is checking when composing.

 

How do I additionally get 1 file with 17 pages still labeled individually for each record?

 

Thanks,

Jeremy

Link to comment
Share on other sites

You can't get both the set of 17 individual files, and one single file with all 17 pages, in one composition pass. You would need two different composition runs. This is something that's fairly easy to automate with FusionPro Server, by modifying the CFG file to change the "OutputSource" value from "byrecord" to "onefile" for the second run.

 

With Creator, you could base whether to output multiple files or single files by using the new "arbitrary chunking" method instead of static chunking. To do this, uncheck the "Output to multiple files" box, and delete the OnNewOutputFile rule, and instead, conditionally call the FusionPro.Composition.OpenNewOutputFile function in OnRecordStart. You can pass the same data in the FusionPro.Composition.OpenNewOutputFile function that you previously assigned to FusionPro.Composition.outputFileName. For instance:

//This goes in OnRecordStart.
if (Field("MutlipleFiles") == "true")
   FusionPro.Composition.OpenNewOutputFile(Field("YourFieldName") + "." + FusionPro.Composition.outputFormatExtension);

 

Unfortunately, there's no way to put page labels on the output PDF.

Link to comment
Share on other sites

If I understand correctly, you want each page of each record to be output to its own PDF and named accordingly? So you'd end up with 17 PDFs for record one named:

"Record1_Page1.pdf"

"Record1_Page2.pdf"

etc...

But, for proofing purposes you'd like all of the pages to be output to one PDF named:

"Record1_proof.pdf"

"Record2_proof.pdf"

 

You can do that by putting this into your OnRecordStart rule:

var proof = true;
var page = 'proof';
var pageNames = [
   'Page1',
   'Page2',
   'Page3',
   // .. etc ..
   'Page17'
];

if (proof) 
   for (var i in pageNames)
       FusionPro.Composition.SetBodyPageUsage(pageNames[i], true);
else {
   FusionPro.Composition.repeatRecordCount = pageNames.length;
   page = pageNames[FusionPro.Composition.repeatRecordNumber-1];
   FusionPro.Composition.SetBodyPageUsage(page, true);
}

FusionPro.Composition.OpenNewOutputFile('Record' + FusionPro.Composition.inputRecordNumber + '_' + page + '.' + FusionPro.Composition.outputFormatExtension);

Assuming you don't want to create a proof each time you compose the template, you can adjust the output behavior by changing the 'proof' variable. As the name suggests, if 'proof' is set to true, a 17 page PDF is output per record; if it's set to false, 17 single-paged PDFs are output per record.

 

If for some reason you want to output single pdfs and proofs every time you run the job, you can use this code instead:

var pageNames = [
   'Page1',
   'Page2',
   'Page3',
   // .. etc ..
   'Page17'
];


FusionPro.Composition.repeatRecordCount = pageNames.length + 1;
page = pageNames[FusionPro.Composition.repeatRecordNumber-1] || 'proof';

if (page == 'proof')
   for (var i in pageNames)
       FusionPro.Composition.SetBodyPageUsage(pageNames[i], true);
else
   FusionPro.Composition.SetBodyPageUsage(page, true);

FusionPro.Composition.OpenNewOutputFile('Record' + FusionPro.Composition.inputRecordNumber + '_' + page + '.' + FusionPro.Composition.outputFormatExtension);

Link to comment
Share on other sites

If I understand correctly, you want each page of each record to be output to its own PDF and named accordingly? So you'd end up with 17 PDFs for record one named:

"Record1_Page1.pdf"

"Record1_Page2.pdf"

etc...

But, for proofing purposes you'd like all of the pages to be output to one PDF named:

"Record1_proof.pdf"

"Record2_proof.pdf"

 

This is exactly what I wanted to do!

 

If for some reason you want to output single pdfs and proofs every time you run the job, you can use this code instead:

var pageNames = [
   'Page1',
   'Page2',
   'Page3',
   // .. etc ..
   'Page17'
];


FusionPro.Composition.repeatRecordCount = pageNames.length + 1;
page = pageNames[FusionPro.Composition.repeatRecordNumber-1] || 'proof';

if (page == 'proof')
   for (var i in pageNames)
       FusionPro.Composition.SetBodyPageUsage(pageNames[i], true);
else
   FusionPro.Composition.SetBodyPageUsage(page, true);

FusionPro.Composition.OpenNewOutputFile('Record' + FusionPro.Composition.inputRecordNumber + '_' + page + '.' + FusionPro.Composition.outputFormatExtension);

I used second set of code you posted.

 

It's exactly what I needed!

 

Thanks Step!

 

Jeremy

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