Receipt Headers and Footers Overview

   Journey Manager (JM) The transaction engine for the platform. |   System Manager / DevOps |  All versions This feature is related to all versions.

When Manager creates a PDF receipt, it uses phantomjs to render each header and footer in a separate HTMLMaestro forms are fundamentally built using HTML 5. The structure of the form and the text displayed in the form are all configured and established using HTML5. HTML is the standard markup language for creating Web pages and stands for Hypertext Markup Language. HTML 5 describes the structure of a Maestro form. DOM prior to generating the receipt. This has several consequences:

Header and Footer Templates

The headers and footers properties, stored in a JSON file, allow you to specify template rules that a receipt service runs to determine the content of a header and a footer. Click Receipt Properties Json to view a JSON file of your render receipt service, for example Dynamic PDF Receipt 2 Service. Each rule has a pageFilter and template property.

The template property contains the HTML that defines the header and footer content. The tokens ${page}and ${numPages} will be replaced with the current page number and total number of pages respectively. Page numbering will start from 1. The content must be a single HTML element so if you need multiple elements, be sure to wrap them in an appropriate <div> element.

The pageFilter property is a string that contains either the page number or a * to match all pages not otherwise filtered.

You can enable logging of the templates used by setting the config.logHeadersFooters property to true.

Custom Headers and Footers In a Form

Forms can optionally use JavaScriptJavascript (JS) is a scripting languages, primarily used on the Web. It is used to enhance HTML pages and is commonly found embedded in HTML code. JavaScript is an interpreted language. Thus, it doesn't need to be compiled. to control the content and styling of headers and footers. You may want to do this for example to inject calculated or dynamic content in the header or footer. To allow a form to control the header and footer behavior first you will need to make sure the config.disableFormOverrides property of the JSON options file is set to false.

You will then need to inject a function into the window object of your form using JavaScript inside your form as in the example below.

window.phantomReceiptCallback = function(actionName,data) {
if (actionName=="orientation") {
	// return either "landscape" or "portrait" or fall 
	// this action is only invoked once per form 
}
if (actionName=="format") {
	// return the paper format eg "A4","letter",etc or fall 
	// this action is only invoked once per form 
}
if (actionName=="margin") {
	// return a JSON object defining the margin eg {"top": "0.5cm","left": "0.5cm","bottom": "0.5cm","right":"0.5cm"} or fall  
	// this action is only invoked once per form 
}
if (actionName=="headerHeight") {
	// return the header height  eg "1cm" or fall
	// this action is only invoked once per form 
}
if (actionName=="footerHeight") {
	// return the footer height  eg "1cm" or fall
	// this action is only invoked once per form 
}
if (actionName=="header") {
	// return the header template string eg "&lt;p&gt;This is the header&lt;/p&gt;" or fall 
	// you can specify the tokens ${page} and ${numPages} in the template you are returning and they will be replaced appropriately
	// you can access the current page and number of pages programmatically by using data.pageNum and data.numPages respectively
	// this action is invoked for every page on the form 
}
if (actionName=="footer") {
	// return the footer template string eg "&lt;p&gt;Page ${page} of ${numPages}&lt;/p&gt;" or fall  
	// you can specify the tokens ${page} and ${numPages} in the template you are returning and they will be replaced appropriately 
	// you can access the current page and number of pages programmatically by using data.pageNum and data.numPages respectively
	// this action is invoked for every page on the form 
}
// NOTE: always return the value defined in Manager if not explicitly overriden above
return data.defaultValue; // this is the value from the JSON options file
};

Here is an example of using a form function to inject the tracking code into the form footer on page 1 for a Composer form. You can for example add this JavaScript to a composer form by dropping a Business Rule [General Purpose] with the below script content.

window.phantomReceiptCallback = function(actionName,data) {
	if (actionName=="footer") {
		if (data.pageNum==1) {
			var trackingCode = sfc.getPhaseValue("TrackingCode");
			return "&lt;p class='phantom-footer'&gt;Page ${page} of ${numPages} - "+trackingCode+"&lt;/p&gt;";
		}
		return "&lt;p class='phantom-footer'&gt;Page ${page} of ${numPages}&lt;/p&gt;";
	}
	// NOTE: always return the value defined in Manager if not explicitly overriden above
	return data.defaultValue; // this is the value from the JSON options file
};

Next, learn how to configure receipt headers and footers.