Jump to content

Compose Record # with field name for box labels


jpmiller

Recommended Posts

It would be easier to offer more specific suggestions if I had the data file, as well as an actual example of multiple records of output (even if it's "dummied up").

 

But it looks like you're just doing a fairly basic two-sided, two-up stacked imposition. So you would start out with a two-page "one-up" FusionPro PDF template, with two pages, each 5.5x8.5" (half the size of the imposed 11x8.5" sheet). Get that set up to correctly generate non-imposed or "one-up" output. Then you can go into FP Imposer and set up an FPI file with the 5.5x8.5" page size, the 11x8.5" sheet size, a stack repeat of 2500, and a horizontal repeat of 2, and use that for your composition. I'm pretty sure that will generate the imposed output you want.

Link to comment
Share on other sites

Hi Dan,

Attached is a .csv and FP template that I would like to create to generate box labels of printed items.

The box label is to have the first and last record of that template in that box.

I usually just open the .csv document and copy the info from the appropriate record number.

i.e.,(Label 1)

record #1 value of field name "first";

then record #2500 value of field name "first";

i.e.,(Label 2)

record #2501 value of field name "first";

then record #5000 value of field name "first";

and so on. A little tedious, but gets the job done.

I am looking for a way to automate the creation of the box labels.

I hope this is a bit more clear.

I understand if this is not possible as it seems pretty difficult to automate.

Thank you,

Label Sheets_FP.pdf

Edited by Dan Korn
Removed data file containing real customer information.
Link to comment
Share on other sites

Okay, thanks for posting the data file. I did ask you to do that. But I did NOT expect you to post actual people's data to a public forum such as this. I'm not a lawyer, but even though it's just names and addresses, I suspect that's probably a HIPAA violation (which is ironic since your template says, "HIPAA COMPLIANT"). At the very least, it's not good handling of customer data. So I've removed that data file. You should have a sample data file with dummy data, and you should probably use it for the entirety of your template building and testing. I'm working on your template using the data file from the Cellphone tutorial installed with FusionPro. It only has 650 records, so it's not perfect for testing your batches of 2500 records, but that number of records per box/label can be easily configured in a rule in the job.
Link to comment
Share on other sites

I think I understand what you're doing now. You're not trying to compose every record in the data file; you just need to denote ranges of the data. This isn't too hard to do, with a little bit of JavaScript.

 

The attached template does what I think you want, with the data file you posted earlier (since removed), though anyone can try it with the cellphone.txt data file in the FusionPro Tutorials folder, or really any data file, by pointing to that data file in the Data Source Wizard, and modifying the lines at the top of OnRecordStart, which looks like this:

// For testing with dummy data file cellphone.txt:
//var recordsPerBox = 50;
//var nameFieldName = "Lname";

// For production, with live data "file for box label.csv":
var recordsPerBox = 2500;
var nameFieldName = "first";

var data = new ExternalDataFileEx(PrimaryInputFile());
var totalRecs = data.recordCount;
var numBoxes = Math.ceil(totalRecs / recordsPerBox);
FusionPro.Composition.repeatRecordCount = numBoxes;
var boxNum = FusionPro.Composition.repeatRecordNumber;
var boxStartRec = (boxNum - 1) * recordsPerBox + 1;
var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);

FusionPro.Composition.AddVariable("totalRecs", totalRecs);
FusionPro.Composition.AddVariable("boxNum", boxNum);
FusionPro.Composition.AddVariable("numBoxes", numBoxes);
FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);
FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);
FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));
FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));

The text boxes in the template use the variables added above. The only other thing the job needs is this in OnJobStart:

// Don't compose every record.  In OnRecordStart, we'll repeat for the number of box labels we need.
FusionPro.Composition.composeAllRecords = false;
FusionPro.Composition.startRecordNumber = 1;
FusionPro.Composition.endRecordNumber = 1;

With your data file, this outputs 14 pages (labels), where the first shows the names from records 1 and 2500, and the last shows the names from records 32501 and 33843.

Label Sheets_FP-Dan-1.pdf

Link to comment
Share on other sites

Here is the final JavaScript. I duplicated it for each instance I needed and changed the return value accordingly. Had to add var boxStartName and var boxEndName, Also changed OnRecordStart to OnJobStart. Thank you for your help with this! This will be a valuable time saver. :):):)

 

// automation of box label entries

// nameFieldName should be mapped to appropiate field use

var recordsPerBox = 2500;

var nameFieldName = "first";

 

var data = new ExternalDataFileEx(PrimaryInputFile());

var totalRecs = data.recordCount;

var numBoxes = Math.ceil(totalRecs / recordsPerBox);

FusionPro.Composition.repeatRecordCount = numBoxes;

var boxNum = FusionPro.Composition.repeatRecordNumber;

var boxStartRec = (boxNum - 1) * recordsPerBox + 1;

var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);

var boxStartName = (data.GetFieldValue(boxStartRec, nameFieldName));

var boxEndName = (data.GetFieldValue(boxEndRec, nameFieldName));

 

FusionPro.Composition.AddVariable("totalRecs", totalRecs);

FusionPro.Composition.AddVariable("boxNum", boxNum);

FusionPro.Composition.AddVariable("numBoxes", numBoxes);

FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);

FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);

FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));

FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));

return boxEndName;

Link to comment
Share on other sites

  • 3 months later...

I am trying to rework the math of the rule so that a batch is split in two for boxing purposes with no more than 2,500 per box.

 

 

Here is the existing rule.

// I think there needs to be a loop here to determine the current batch quantity

 

var runBatch = (i !< (cannot be greater than) 5000);

 

// insert for Loop here to check for i > 5000

// else if runBatch =< 5000

 

var recordsPerBox = runBatch / 2;

 

var nameFieldName = "first";

 

var data = new ExternalDataFileEx(PrimaryInputFile());

var totalRecs = data.recordCount;

var numBoxes = Math.ceil(totalRecs / recordsPerBox);

FusionPro.Composition.repeatRecordCount = numBoxes;

var boxNum = FusionPro.Composition.repeatRecordNumber;

var boxStartRec = (boxNum - 1) * recordsPerBox + 1;

var boxEndRec = Math.min(boxNum * recordsPerBox, totalRecs);

 

 

 

FusionPro.Composition.AddVariable("totalRecs", totalRecs);

FusionPro.Composition.AddVariable("boxNum", boxNum);

FusionPro.Composition.AddVariable("numBoxes", numBoxes);

FusionPro.Composition.AddVariable("boxStartRec", boxStartRec);

FusionPro.Composition.AddVariable("boxEndRec", boxEndRec);

FusionPro.Composition.AddVariable("boxStartName", data.GetFieldValue(boxStartRec, nameFieldName));

FusionPro.Composition.AddVariable("boxEndName", data.GetFieldValue(boxEndRec, nameFieldName));

VDP Label Sheet_new.pdf

label test file_more than 5000.csv.zip

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