Description

LLM does not support printing multiple page documents, but applying a script can simulate this behavior to an extent. The following example demonstrates the simulation of multi-page form printing using a script.

How to simulate multi-page form printing using a script

Caution: A large number of pages or number of fields on a label may impact performance, so implement this script with caution and monitor performance.

Create a label with the following fields:

  • Script Data Source Field (Script) (non-printing)
  • Two Fixed Data Source Fields (linesperpage & **QUANTITY) (non-printing) Note: The field name **QUANTITY must be used.
  • Three Keyboard Source Fields (page_count, Qty, INC) (INC is non-printing)
  • Three Fixed Text/Label fields:
    • First field named Lab01 and set Label Text = 'Pages'
    • Second field named Lab02 and set Label Text = 'of'
    • Third field named Lab03 and set Label Text = 'Below are multiple fields layered one on top of the other'
  • Enough Keyboard Data Source fields to accept the maximum number of items to be printed using an incrementing naming scheme. (i.e., Text1, Text2, Text3... Text18, Text19, Text20...)
    • The positioning of these fields is the key to making this work - the fields must be arranged such that fields for the second page exactly overlap the fields for the first page.
    • The script will turn on the proper layer for the page being printed.
  • Set the value for the **QUANTITY field to the maximum number of pages that could be printed
  • Set the value for the linesperpage field to the number of lines items per page
  • Position the page_count and Qty fields with an "of" between them to create the page count. (i.e., 1 of 4, 2 of 4, 3 of 4...)

Sample Label File

Simulate_multiple_page_sample.lwl


The following sample script demonstrates this concept. You may use this script to get started and alter it to suit your needs.

//reset incrementing fields
var inc = Number(label.fields.field.(@name=='INC').@data);
if (inc=="")
{
label.fields.field.(@name=='INC').@data=0;
}
var page = Number(label.fields.field.(@name=='page_count').@data);
if (page=="")
{
label.fields.field.(@name=='page_count').@data=0;
}
// Increment page by 1
page+=1;
//check for blank pages and adjust quantity
var lines = Number(label.fields.field.(@name=='linesperpage').@data);
var maxpages = Number(label.fields.field.(@name=='**QUANTITY').@data);
var field_count = maxpages*lines;
var textArray=new Array();
for (i=1;i<=field_count;i++)
{
textArray[i]=label.fields.field.(@name=='Text'+i).@data;
}
var quantity = label.fields.field.(@name=='**QUANTITY').@data;
var blanks=0;
for (i=1;i<=field_count;i++)
{
if(textArray[i]=="")
{
blanks+=1;
if (i%lines==0 && blanks==lines)
{
quantity-=1;
}
}
if (i%lines==0)
{
blanks=0;
}
}
label.fields.field.(@name=='Qty').@data=quantity;
//ensure all fields are set to non-printing
for (i=1;i<=field_count;i++)
{
label.fields.field.(@name=='Text'+i).@printingField=false;
}
//turn on fields for printing page
for (i=1;i<=lines;i++)
{
var fieldvalue = (i*1) +(inc*1);
label.fields.field.(@name=='Text'+fieldvalue).@printingField=true;
}
// turn "off" blank pages and cancel page increment
inc*=1;
blanks=0;
for (i=1;i<=lines;i++)
{
if(textArray[inc+i]=="")
{
blanks+=1;
}
}
if(blanks==lines)
{
label.fields.field.(@name=='Lab01').@printingField=false;
label.fields.field.(@name=='Lab02').@printingField=false;
label.fields.field.(@name=='Lab03').@printingField=false;
label.fields.field.(@name=='page_count').@printingField=false;
label.fields.field.(@name=='Qty').@printingField=false;
page-=1;
}
else
{
label.fields.field.(@name=='Lab01').@printingField=true;
label.fields.field.(@name=='Lab02').@printingField=true;
label.fields.field.(@name=='Lab03').@printingField=true;
label.fields.field.(@name=='page_count').@printingField=true;
label.fields.field.(@name=='Qty').@printingField=true;
}
//Increment INC value for next page and output data to page and INC value so they are carried to next label
label.fields.field.(@name=='page_count').@data=page;
inc+=lines;
label.fields.field.(@name=='INC').@data=inc;

Related Articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Article Number

2017102

Versions

Loftware Label Manager 9.5.3.0 or later

Environment

Supported LPS family product environment using ZPL or PCL printers

This table provides information that is visible only to Loftware users.

Linked Jira
Incident Number 
AuthorMichael Alley
Review Date