JeremyT Posted February 10, 2015 Posted February 10, 2015 I have a large file with 5000 records that I would like to have chunked into 250 records per output pdf. What code do I need so that when outputting files it adds the starting and ending record of that chunk on the output pdf. For example: Output Job 1-250.pdf Output Job 251-500.pdf Output Job 501-750.pdf Thanks, Jeremy Quote
step Posted February 10, 2015 Posted February 10, 2015 I think you'd basically just have to name output file the current record (i.e. 1) and then add on the chunk size (i.e. 250) when you're naming the file. Where are you setting the chunk size? If it's in the code, you might do something like this: OnRecordStart var chunkSize = 250; var curr = FusionPro.Composition.inputRecordNumber; var outputName = "Output Job " + curr + "-" + (curr + (chunkSize-1)); //return outputName // Output Job 1-250; if (FusionPro.Composition.inputRecordNumber % chunkSize == 1){ FusionPro.Composition.OpenNewOutputFile(outputName + "." + FusionPro.Composition.outputFormatExtension); } If you're setting it in the the composition dialog page, you may want to try something like this: var chunkSize = Int(FusionPro.Composition.JobOptions["RecordsPerChunk"]); var curr = FusionPro.Composition.inputRecordNumber; var outputName = "Output Job " + curr + "-" + (curr + (chunkSize-1)); //return outputName // Output Job 1-250; if (FusionPro.Composition.inputRecordNumber % chunkSize == 1){ FusionPro.Composition.OpenNewOutputFile(outputName + "." + FusionPro.Composition.outputFormatExtension); } Quote
JeremyT Posted February 11, 2015 Author Posted February 11, 2015 If you're setting it in the the composition dialog page, you may want to try something like this: var chunkSize = Int(FusionPro.Composition.JobOptions["RecordsPerChunk"]); var curr = FusionPro.Composition.inputRecordNumber; var outputName = "Output Job " + curr + "-" + (curr + (chunkSize-1)); //return outputName // Output Job 1-250; if (FusionPro.Composition.inputRecordNumber % chunkSize == 1){ FusionPro.Composition.OpenNewOutputFile(outputName + "." + FusionPro.Composition.outputFormatExtension); } I am chunking it in the composition dialog so I used the code from above. Thanks! The job I am working on has 5076 records so the last pdf output is labelled 5001-5250. Is there a way to have it labelled by the last record in the output pdf? Jeremy Quote
step Posted February 11, 2015 Posted February 11, 2015 You can do a check to see if the chunk is going to be less than the total number of records. If it is, use the chunk size. If it isn't, you know you're at the last chunk and you should just use the total number of records instead: var chunkSize = Int(FusionPro.Composition.JobOptions["RecordsPerChunk"]); var curr = FusionPro.Composition.inputRecordNumber; var totalRecords = FusionPro.Composition.totalRecordCount; var range = curr + (chunkSize-1); if (range >= totalRecords) { range = totalRecords; } var outputName = "Output Job " + curr + "-" + range; if (FusionPro.Composition.inputRecordNumber % chunkSize == 1){ FusionPro.Composition.OpenNewOutputFile(outputName + "." + FusionPro.Composition.outputFormatExtension); } Keep in mind that "FusionPro.Composition.totalRecordCount" requires preprocessing to be done before it's accessible. If you are using an imposition then FP preprocesses already, if not you will need to force preprocessing in the OnJobStart callback: FusionPro.Composition.forcePreprocessing = true; 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.