Jump to content

Name the output based on a variable field?


Recommended Posts

Posted

I would like to output PDF as one record per file, but have each output file be named from one of the variables in the database.

 

What I have is a list of orders to be fulfilled; these orders are for legal terms and conditions packets. Each order is a line entry that generates a variable letter to the customer, plus describes which T&C document gets packaged with that letter. If I could generate the letter as a single PDF, I have a third party system that can then bundle that letter with the existing T&C document that's appropriate for that letter, create a new file that's the entire customer packet, and send everything to the printer.

 

But what I need is for that single record PDF output to be named by a variable in the order list, instead of the usual "project-Output1.pdf", "project-Output2.pdf", etc. I need it to be named "order1.pdf", "order2.pdf", or whatever each record is called in the database. Can FPro do this? I don't think so...

 

You would think that I could call the T&C from within FPro, but the real stopper here is that some T&C documents are legal sized, while some are letter sized--and there's zero organization of the order list, or knowledge built into the order list regarding which type is which. I can't create a letter size document and pull in a legal size T&C page, for example, or vice-versa. The T&C documents are all PDF already anyway, and not tagged text or something similar.

 

An alternative would be to do this within FPRo, if FPro could insert the proper existing T&C document as is--already in PDF format--immediately behind the variable letter during composition. So once the single page variable letter for that line entry is composed based on that entry, FPro would then be told to look at the "T&C document" field and go to a specific folder and find the document named in that field, and simply append the document itself. Again, some of these T&C documents are letter sized, some are legal size.

 

I don't think FPro can do that either, can it?

 

I would strongly prefer to do the first choice, outputting the results of each record individually as its own document, with the appropriate name from the database, as my printing system works extremely well for this; it will nicely offset each individual print job along with a colored banner page.

 

Or can I program FPro, using custom Postscript, to do the offset and custom banner page itself at the beginning of each record? If that's the case, maybe I could do the entire thing within FPro, output Postscript, and send a monolithic output file directly to the printer.

 

Thanks for any ideas on this.

Posted
I would like to output PDF as one record per file, but have each output file be named from one of the variables in the database.

...

But what I need is for that single record PDF output to be named by a variable in the order list, instead of the usual "project-Output1.pdf", "project-Output2.pdf", etc. I need it to be named "order1.pdf", "order2.pdf", or whatever each record is called in the database. Can FPro do this? I don't think so...

Sure it can! In the Composition Settings dialog, on the Output tab, check "Output to multiple files" and set "Number of records per file" to 1. (Make sure to UNcheck "Different number of records in first file.") Then, from the Rules dialog, click "New", then click "Callback" and select OnNewOutputFile and "Next". Paste this syntax into the Rule Editor:

FusionPro.Composition.outputFileName = Field("YOUR_FIELD_NAME") + ".pdf";

Specifying whatever data field name you want to use to name each output file. Click OK a couple times, and you should be good to go.

  • 3 months later...
Posted

Can the same thing be acheived using the fusionpro command line?

fusionpro.exe <instance file> <format (the .dif) file> <config file> <output file>

 

where the <output file> changes based on the records in the input file?

 

Please advise!

Posted
Can the same thing be acheived using the fusionpro command line?

fusionpro.exe <instance file> <format (the .dif) file> <config file> <output file>

 

where the <output file> changes based on the records in the input file?

No, you have to use the OnNewOutputFile rule. How would you indicate which record in the input file to base the output file name on from the command line?

  • 5 months later...
Posted

Dan,

 

Can you help me figure something out? I am using the OnNewOutputFile Callback rule:

 

FusionPro.Composition.outputFileName = Field("Order_Number") + "output.pdf";

 

I have a file with 800 records and a field called Order Number.

Order 12345 has 100 records

Order 54321 has 200 records

Order 99999 has 500 records

 

I would like to output file

12345.pdf with 100 records

54321.pdf with 200 records

99999.pdf with 500 records

Posted
Supposedly, the forthcoming version 8 is said to support output of multiple, multi-record files per data set, but currently that is NOT an option. This thread talks about outputting single record files which is possible now. For now, you will need to compose portions of your data separately, or break your data into 3 separate files first.
Posted

Thanks, I will break my file into 3 files, I wonder, instead a single record, can I break it out by 100?

 

12345.dbf

54321_1.dbf

54321_2.dbf

99999_1.pdf

99999_2.pdf

99999_3.pdf

99999_4.pdf

99999_5.pdf

 

Or can I break it out by single record then program to put them back together?

Posted
Thanks, I will break my file into 3 files, I wonder, instead a single record, can I break it out by 100?

Sure, just set "Number of records per file" to 100.

 

Also, as Eric noted, FusionPro 8 will give you the ability to define arbitrary chunk sizes (number of records in an output file) in a rule, instead of chunks all the same size.

Posted

Dan,

 

I set "Number of records per file" to 100 and used a file with 200 records, but it only outputs one file at 100 records. How do I get two files with 100 records but a file name of Output1.pdf Output2.pdf?

 

 

I am still using

FusionPro.Composition.outputFileName = Field("Order_Number") + "output.pdf";[/Code]

Posted

It looks like the file is being overwritten. I set "Number of records per file" to 1 and used a file with 100 records, I got one file with 1 record. The last record 100.

 

Is there some JavaScript I need to add to my callback? Or am I missing something?

Posted

If you're running FP7.2, you'll need to manually call the output rule at the start of the job. Paste this into your "OnJobStart" callback:

 

Rule("OnNewOutput");

Posted

Step,

 

Thanks for the help, I added the Rule but my results were the same.

 

I would like to thank everyone for helping me, your knowledge helped me figure out a temporary solution for my project. Here is the code for my OnNewOutputFile Callback Rule. It's not pretty but it gets the job done.

 

var SeqNum = Field("Account_Seq");
var SeqOut = "0"

if (SeqNum = 1)
SeqOut = "1";
else if (SeqNum == 101)
SeqOut = "2";
else if (SeqNum == 201)
SeqOut = "3";
else if (SeqNum == 301)
SeqOut = "4";
else if (SeqNum == 401)
SeqOut = "5";

FusionPro.Composition.outputFileName = Field("Order_Number") + "output" + SeqOut + ".pdf";

 

In Compostiton Setting I checked "Output to multiple files" and set "Number of records per file:" to 100. My import file had 2,300 records. After composing I got 23 files back. I had 15 unique Order_Numbers ranging from 100, 200, or 300 records.

 

Example:

11111output1.pdf

22222output1.pdf

22222output2.pdf

33333output1.pdf

33333output2.pdf

33333output3.pdf

 

Is there a simple way to do this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...