Dyamic Duplexing

Hi we have a section in Pres Connect that is a simplex template. But on this we can put a variety of PDF backgrounds some being 1 page and the other 2 pages.

Is there a way we can set the Duplexing options by the number of pages in the PDF?

Hello @timj1980,

Yes, there actually is.

Let’s say that you have applied an Extract step on the DataMapper configuration side and that this Extract step contains a field with name pageCount and that the JavaScript code steps.totalPages has been applied to this field. In this case you can apply something like the following to your Print Template:

Control Script

Name: Example

let printSection = merge.template.contexts.PRINT.sections["Section 1"];
let field = "";
let pageCount = 0;

field = record.fields.pageCount;

if (field !== "") pageCount = parseInt(field);

if (pageCount === 1) {
	printSection.sheetConfig.duplex = false;
} else if (pageCount === 2) {
	printSection.sheetConfig.duplex = false;
}

Tip: Click with the right mouse button on the Control folder in the Scripts pane of the Designer application and go to New > Control Script to add new Control Script to a Print Template.

1 Like