JeremyT Posted November 26, 2013 Posted November 26, 2013 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 Quote
Dan Korn Posted November 26, 2013 Posted November 26, 2013 (edited) 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 November 26, 2013 by Dan Korn typo Quote
JeremyT Posted November 26, 2013 Author Posted November 26, 2013 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 Quote
Dan Korn Posted November 26, 2013 Posted November 26, 2013 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. Quote
JeremyT Posted November 26, 2013 Author Posted November 26, 2013 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. Quote
Dan Korn Posted November 26, 2013 Posted November 26, 2013 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); } Quote
JeremyT Posted December 2, 2013 Author Posted December 2, 2013 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); Quote
Dan Korn Posted December 2, 2013 Posted December 2, 2013 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. Quote
JeremyT Posted December 3, 2013 Author Posted December 3, 2013 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 Quote
step Posted December 4, 2013 Posted December 4, 2013 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); } Quote
JeremyT Posted December 4, 2013 Author Posted December 4, 2013 I'm assuming you're trying to replace everything in red with "F-". I also want the magenta text removed. CARD_00000054512022013.CSV So it would look like this "Form F-545120213.pdf" Quote
step Posted December 4, 2013 Posted December 4, 2013 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); } Quote
JeremyT Posted December 4, 2013 Author Posted December 4, 2013 I ended up with "Form F-5451202.pdf" I am missing the 13 that comes just before the .CSV in the data file name. Quote
step Posted December 4, 2013 Posted December 4, 2013 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); } Quote
JeremyT Posted December 4, 2013 Author Posted December 4, 2013 I was missing the second capture. Thanks. Quote
JeremyT Posted December 4, 2013 Author Posted December 4, 2013 Thanks for the help-merge works! Quote
JeremyT Posted December 5, 2013 Author Posted December 5, 2013 Is there a way to get the output pdf of Forms A, B, C, D, and E to pick up part of the data file name like what is being done for Form F? Quote
JeremyT Posted December 6, 2013 Author Posted December 6, 2013 Is there a way to get the output pdf of Forms A, B, C, D, and E to pick up part of the data file name like what is being done for Form F? Is this possible? Quote
step Posted December 6, 2013 Posted December 6, 2013 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(); Quote
JeremyT Posted December 6, 2013 Author Posted December 6, 2013 I get the following error message when composing: OnJobStart, line 1: ReferenceError: OnNewOutputFile is not defined Quote
step Posted December 6, 2013 Posted December 6, 2013 My mistake. OnJobStart should say: Rule("OnNewOutputFile"); Quote
JeremyT Posted December 6, 2013 Author Posted December 6, 2013 Now I get a pdf named "Form A-E" with Form F pages in it. Quote
JeremyT Posted December 10, 2013 Author Posted December 10, 2013 Now I get a pdf named "Form A-E" with Form F pages in it. Any ideas on how to fix this? Quote
JeremyT Posted December 17, 2013 Author Posted December 17, 2013 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? Quote
Dan Korn Posted December 17, 2013 Posted December 17, 2013 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. Quote
Recommended Posts
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.