Objectif Lune joins Upland Software.Learn more >

Back to all How-tos

Create blank pages on field value

This How-To will show you how to create any number of blank pages in your output, using a number found in a field value.

Method 1: Using an object with a forced page break

The first method is a little simple, but has the disadvantage of printing pages without contents but still using the Master Page for the section.

The Script

To execute this method, simply create a new Script in the Scripts Pane set to the body selector, and copy the contents below:

var pageCount = record.fields["blank_pages"];

for (i = 0; i < pageCount; i++) { 
    results.append('<div style="page-break-before: always;">&nbsp;</div>');
}

How it works

Overflow in Connect works in a simple way: it creates as many pages as necessary to output all the contents located within the section, however many pages that takes. And, since Connect uses a simple pagination system (*simple* being a relative term) based on HTML and CSS, we can “trick” it into thinking it has new contents. The <div> element added by the script has a CSS property called page-break-before which forces, you guessed it, a page break before. And even if there is no other contents between two of these elements, each of them will for a new page.

For more information on page-break-before, see the Mozilla Developer Network – page-break-before.

Method 2: With a separate section

In order to get truly blank pages (without the master page of the main section being used), we need to create a new section and a new master page, then apply the same trick to it.

This is only available in version 1.3 and higher of Connect, which lets us run scripts conditionally.

Step 1: Preparing the master page and section

The first step is to prepare the resources necessary. These resources can be added to any existing template.

  1. Create a new Master Page and ensure that it is completely empty. Call it Blank
  2. Create a new Section also called Blank and delete any contents within.
  3. In the Sheet Configuration dialog for the new section, check Same for all positions, and select Blank as a Master Page.

Step 2: Creating the script

The script used here will be identical to Method 1, but there is in fact one difference: we need to make sure this script is only run on the blank section.

  1. Create the same script as above on the body selector, with the same code sample
  2. Create a new Folder in the Scripts Pane, call it Blank Page, and drag the new script to this folder.
  3. Right-click on the folder, go into Properties and uncheck all sections except for Blank.

Leave a Reply

Your email address will not be published. Required fields are marked *