Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 10th, 2015, 01:30 PM
JeremyT JeremyT is offline
Regular Contributor
 
Join Date: Apr 2013
Location: Middleton, WI
Posts: 86
Default Label output file with start record and end record

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
__________________
Jeremy
Acrobat Pro DC 2017
FusionPro VDP Creator 10.0.16
Mac OS X 10.11.6
Reply With Quote
  #2  
Old February 10th, 2015, 02:54 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Label output file with start record and end record

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
Code:
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:
Code:
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);
}
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old February 11th, 2015, 11:10 AM
JeremyT JeremyT is offline
Regular Contributor
 
Join Date: Apr 2013
Location: Middleton, WI
Posts: 86
Default Re: Label output file with start record and end record

Quote:
Originally Posted by step View Post
If you're setting it in the the composition dialog page, you may want to try something like this:
Code:
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
__________________
Jeremy
Acrobat Pro DC 2017
FusionPro VDP Creator 10.0.16
Mac OS X 10.11.6
Reply With Quote
  #4  
Old February 11th, 2015, 02:17 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 957
Default Re: Label output file with start record and end record

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:
Code:
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:
Code:
FusionPro.Composition.forcePreprocessing = true;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:27 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.