Jump to content

Output to multiple files, arbitrary chunks, name output pdf


JeremyT

Recommended Posts

I am trying to do a merge for business cards we merge daily.

 

There are 6 different styles of cards. Currently I use FusionPro.Composition.SetBodyPageUsage in OnRecord Start based on what kind of business card it is.

 

In the end I need 2 files-cards one sided and cards two sided. 5 styles are one sided, 1 style is two sided.

 

Currently I am running 2 different merges to get 2 files for printing.

 

How do I get one sided cards and two sided cards into 2 files?

 

Also when outputting the pdf I'd like to have the pdf file name get the 9 digit date from the name of the data file.

 

Thanks,

Jeremy

Link to comment
Share on other sites

I am trying to do a merge for business cards we merge daily.

 

There are 6 different styles of cards. Currently I use FusionPro.Composition.SetBodyPageUsage in OnRecord Start based on what kind of business card it is.

 

In the end I need 2 files-cards one sided and cards two sided. 5 styles are one sided, 1 style is two sided.

 

Currently I am running 2 different merges to get 2 files for printing.

 

How do I get one sided cards and two sided cards into 2 files?

You can open a new output file whenever you want, such as when the record changes from one-sided to two-sided, with the FusionPro.Composition.OpenNewOutputFile function in OnRecordStart. But you can't put an arbitrary set of non-contiguous records into a separate output file. I think you need to pre-sort the data into two contiguous groups of records to get two output files like that.

Also when outputting the pdf I'd like to have the pdf file name get the 9 digit date from the name of the data file.

I don't know what you mean by a "9 digit date," but you can do something like this:

FusionPro.Composition.OpenNewOutputFile(FormatDate(Today(), "MM-dd-yyyy") +
   "." + FusionPro.Composition.outputFormatExtension);

Edited by Dan Korn
typo
Link to comment
Share on other sites

Dan,

 

Thanks again for your help.

 

I've added FusionPro.Composition.outputFileFullPathName to change where the file ends up.

 

How do I make 2 separate output files, 1 one sided and 1 two sided? Two sided records are at the end of he data file.

 

Thanks,

Jeremy

Link to comment
Share on other sites

How do I make 2 separate output files, 1 one sided and 1 two sided? Two sided records are at the end of he data file.

Well, I don't know what the criteria is in your data that you can test in a rule to determine when to open the new output file, but you want to do something like this in OnRecordStart:

if (FieldChanged("NumberOfSides"))
 FusionPro.Composition.OpenNewOutputFile();

But the condition in the "if" statement is probably going to be something different. Again, though, I don't know if it's just a matter of checking a field value, but I don't know what else to specifically suggest without knowing more about the job and the data.

Link to comment
Share on other sites

Data file has the form number in it. Form number determines which of 6 body pages is used during merge.

 

Then I want the output pdf to have Form A, Form B, Form C, Form D and Form E (all are 1 sided) in it.

 

Then another output pdf with Form F, which is 2 sided it.

Link to comment
Share on other sites

Data file has the form number in it. Form number determines which of 6 body pages is used during merge.

 

Then I want the output pdf to have Form A, Form B, Form C, Form D and Form E (all are 1 sided) in it.

 

Then another output pdf with Form F, which is 2 sided it.

Okay, so I'm still flying a bit blind here without the actual data file to look at, but I think this is what you want:

if (FieldChanged("form number") && Field("form number") == "Form F")
{
   FusionPro.Composition.OpenNewOutputFile("FormF." +
       FusionPro.Composition.outputFormatExtension);
}

Link to comment
Share on other sites

Dan,

 

I am able to get my merge into two separate files. Problem is that I can't get Forms A, B, C, D, and E in the same file.

 

Currently it makes a file with Form E and then Form F.

 

How do I get Forms A, B, C, D and E in the same file?

 

Here is what I have in the OnRecordStart after FusionPro.Composition.SetBodyPageUsage

 

if (FieldChanged("Card Type") && Field("Card Type") != "Form F")

   FusionPro.Composition.OpenNewOutputFile("All." +
       FusionPro.Composition.outputFormatExtension);

if (FieldChanged("Card Type") && Field("Card Type") == "Form F")

   FusionPro.Composition.OpenNewOutputFile("Form F." +
       FusionPro.Composition.outputFormatExtension);

Link to comment
Share on other sites

Dan,

 

I am able to get my merge into two separate files. Problem is that I can't get Forms A, B, C, D, and E in the same file.

 

Currently it makes a file with Form E and then Form F.

 

How do I get Forms A, B, C, D and E in the same file?

 

Here is what I have in the OnRecordStart after FusionPro.Composition.SetBodyPageUsage

 

[color=Red]if (FieldChanged("Card Type") && Field("Card Type") != "Form F")

   FusionPro.Composition.OpenNewOutputFile("All." +
       FusionPro.Composition.outputFormatExtension);
[/color][color=SeaGreen]
if (FieldChanged("Card Type") && Field("Card Type") == "Form F")

   FusionPro.Composition.OpenNewOutputFile("Form F." +
       FusionPro.Composition.outputFormatExtension);[/color]

Get rid of the first part, in red above. I'm not sure why you added that in the first place.. Did you try with the rule I posted in my previous message? That should work. It's basically the part in green above.

Link to comment
Share on other sites

Dan,

 

I added the text in red because I couldn't get the merge to work correctly with the original code that you posted.

 

The step I was missing was that the Forms A-E get output like a regular output pdf. Once I changed that it worked perfectly with just the green text.

 

The next part I need help with is getting Form F's pdf named. Each day generates a new data file with a new date in it. Today's data file is labeled "CARD_00000054512022013.CSV"

 

I'd like my Form F pdf to be labeled Form F-545120213.pdf . Green text comes from the data file name.

 

 

Thanks!

Jeremy

Link to comment
Share on other sites

I'm assuming you're trying to replace everything in red with "F-".

Today's data file is labeled "CARD_00000054512022013.CSV"

This code uses regex to strip out anything that's not a 1 or greater from the beginning of your input data file's name and replace it with "F-" and appends the extension (.pdf).

if (FieldChanged("Card Type") && Field("Card Type") == "Form F") {
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*).\w+$/,'F-$1.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
}

Link to comment
Share on other sites

Oh okay, I noticed that that was missing but was just thinking it was a typo. Try this:

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

Link to comment
Share on other sites

Hm, worked for me. Did you include the second capture in the replace function (in red)?

if (FieldChanged("Card Type") && Field("Card Type") == "Form F") {
   var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,'Form F-$1[color="Red"]$2[/color].');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);
}

Link to comment
Share on other sites

Create an OnNewOutputFile call back rule and put the code for naming the file in it. And then call the OnNewOutputFile call back rule from the OnJobStart callback rule. Like this:

 

OnNewOutputFile:

var outputName = GetFileName(FusionPro.Composition.inputFileName).replace(/^[^1-9]*([^\.]*)20(\d{2})\.\w+$/,'Form A-E-$1$2.');
   FusionPro.Composition.OpenNewOutputFile(outputName + FusionPro.Composition.outputFormatExtension);

 

OnJobStart:

OnNewOutputFile();

Link to comment
Share on other sites

I've looked through my code several times and can't figure out why this isn't working correctly.

 

Now I am getting a pdf named "Form A-E.pdf" with Form F pages in it.

 

Any ideas?

Well, you may have looked through your code several times, but none of us have seen it, so I'm not sure how we can figure it out.

 

Step and I have been trying to help, but we're looking at your job through a keyhole. Throughout this entire thread, you have not posted a sample job which demonstrates the problem, or even the data, nor have you specified what version of FusionPro and OS you're using.

 

As I said in my first post in this thread:

You can open a new output file whenever you want, such as when the record changes from one-sided to two-sided, with the FusionPro.Composition.OpenNewOutputFile function in OnRecordStart.

And you can give the output file whatever name you want in that function call as well.

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