Jump to content

Output to multiple files, arbitrary chunks, name output pdf


JeremyT

Recommended Posts

Actually, I've kind of lost track of the requirements here, but in addition to getting rid of the other rules, I think you want to change the logic in OnRecordStart (after all the calls to FusionPro.Composition.SetBodyPageUsage) to this:

if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && Field("Form Type")=="Form F")) {
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,Field("Form Type")+'-$1$2.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

When I run with this rule, I get one output file named "Form A-548120513.pdf" with the A-E records, and another named "Form F-548120513.pdf" with the Form F records.

Link to comment
Share on other sites

Dan,

 

Using the code you just provided splits the final pdfs the way I need them.

 

Is there a way to get the pdf with Forms A-E labeled "Combined-" and then date characters from the data file?

 

The pdf for Forms F is labeled correctly.

 

Thanks,

Jeremy

Link to comment
Share on other sites

Is there a way to get the pdf with Forms A-E labeled "Combined-" and then date characters from the data file?

Sure:

if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && Field("Form Type")=="Form F")) {
   var outputPrefix = Field("Form Type")=="Form F" ? "Form F" : "Combined";
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,outputPrefix+'-$1$2.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

Or, you can change the entire rule to something like this:

for (var form = 'A'; form <= 'E'; form = Chr(Asc(form) + 1))
{
   var formName = "Form " + form;
   var isCurrentForm = Field("Form Type") == formName;
   FusionPro.Composition.SetBodyPageUsage(formName, isCurrentForm);
}
var isFormF = Field("Form Type") == "Form F";
FusionPro.Composition.SetBodyPageUsage("Form F Front", isFormF)
FusionPro.Composition.SetBodyPageUsage("Form F Back", isFormF)


if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && isFormF))
{
   var outputPrefix = isFormF ? "Form F" : "Combined";
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,outputPrefix+'-$1$2.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

Link to comment
Share on other sites

Dan, does that work if there is an imposition applied to the job?

It seems like every time I try that code with an imposition applied, the first record is output with the naming convention given in the composition window as discussed here. It's odd because it works correctly if you specify a range of records that is less than the number of records actually in the data file. I thought that preprocessing happened automatically when an imposition file was used. Does preprocessing happen differently when a range of records is specified versus when an imposition is being used?

 

The only work-around to this (that I've seen) is putting the naming convention in an OnNewOutputFile Rule and then calling OnNewOutputFile from OnJobStart to force the naming.

Link to comment
Share on other sites

  • 4 weeks later...
Sure:

if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && Field("Form Type")=="Form F")) {
   var outputPrefix = Field("Form Type")=="Form F" ? "Form F" : "Combined";
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,outputPrefix+'-$1$2.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

 

Dan,

 

I used the code you suggested above.

 

Everything works great!!!

 

Is it possible to put the 2 pdfs output into 3 different locations?

 

Thanks,

Jeremy

Link to comment
Share on other sites

Is it possible to put the 2 pdfs output into 3 different locations?

Sure, just include the full path in the call to FusionPro.Composition.OpenNewOutputFile, something like this:

if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && Field("Form Type")=="Form F")) {
   var outputPrefix = Field("Form Type")=="Form F" ? "Form F" : "Combined";
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,outputPrefix+'-$1$2.');
   var outputPath = "/some path here/folder/etc/"; // or base this on a field value, or whatever
   FusionPro.Composition.OpenNewOutputFile(outputPath + outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

Please note that, with currently released versions of FusionPro, the specified path must already exist. (In the upcoming 9.2 release, the folders will be created as necessary.)

Link to comment
Share on other sites

if (FusionPro.Composition.processedRecordNumber == 1 || (FieldChanged("Form Type") && Field("Form Type")=="Form F")) {
   var outputPrefix = Field("Form Type")=="Form F" ? "Form F" : "Combined";
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,outputPrefix+'-$1$2.');
   var outputPath = "/some path here/folder/etc/"; // or base this on a field value, or whatever
   FusionPro.Composition.OpenNewOutputFile(outputPath + outputName + FusionPro.Composition.outputFormatExtension);
   Print("Changing to output file: " + outputName + FusionPro.Composition.outputFormatExtension);
}

 

Adding the variable outputPath to FusionPro.Composition.OpenNewOutputFile allowed me to tell the composed PDF where to go.

 

How do I get it to go to 3 folders, each on a separate server?

Link to comment
Share on other sites

Adding the variable outputPath to FusionPro.Composition.OpenNewOutputFile allowed me to tell the composed PDF where to go.

 

How do I get it to go to 3 folders, each on a separate server?

Okay, wait. Do you mean that you want each output file to go to its own folder, or do you mean that you want each output file to be copied to three different folders?

 

If you want each output file to go to its own folder, then just program it to do that, something like this:

    var outputPath = Field("Form Type")=="Form F" ? "/Volumes/server1_name/folder_path/etc/" : "/Volumes/server2_name/folder_path/etc/";

Since you're on a Mac, you can't make use of handy UNC paths like on Windows. You have to first mount an external drive from the server, and then OS X assigns it a path under /Volumes. Exactly what the mounted path would be, I can't say; you have to connect to it, then you can do a "Get Info" from the Finder to see the path.

 

If you mean that you want each output file to be copied to three folders, then sorry, but FusionPro VDP Creator doesn't do that. You would either need to write some kind of custom app that watches the output folder, then copies the file to some other folders, or use FusionPro VDP Producer API (FP Server). If you compose via Producer (FP Direct), you can specify a printer hot folder where the output will be copied.

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