Management footer

Avatar

Avatar

tafkap95210

Avatar

tafkap95210

tafkap95210

12-01-2021

Hi there,

i need to manage the display of the footer according to the number of pages for a dataset (page in blue / green), but at the end of this data I have to display another different dataset (Page services) which does not have a footer. I don't know how to fix this problem.

 

- Case 1: the content fits on a single page, so we have the following result:

tafkap95210_2-1610456505576.png

- Case 2: the content spills over onto a second page, so the footer should appear at the bottom of the second page:

tafkap95210_3-1610456639844.png

- Case N pages: a lot of content to display there are N pages, the footer must be displayed on the last page:

tafkap95210_4-1610456951193.png

I don't know where I should place my footer, in the ContentArea? On my page ?

 

Any help will be appreciated.

 

 

 

View Entire Topic

Avatar

Avatar

radzmar

MVP

Avatar

radzmar

MVP

radzmar
MVP

22-01-2021

Okay, it's a bit more complicated, but still doable.

Here's my solution, that works.

radzmar_0-1611337119601.png

 

So the spacer (the red thing) is rezising so the footer is always pushed to the bottom of the last page. 

radzmar_1-1611337233009.png

 

Here the full script: 

 

// Calculate the height of the spacer subform 
// Put this into its layout ready event
var oSpacer = this.Spacer, // reference to spacer object
	nPage = xfa.layout.absPage(oSpacer), // page number, where spacer is currently present. This is the target page.
	nSpanPage, // Page number where span starts
	oContents = xfa.layout.pageContent(nPage, "subform"), // reference to all subforms on the target page.
	aRelevantContents = ["Header", "Contents", "Footer"], // names of the relevant ones
	oContentAreaH = Math.round( xfa.layout.h(xfa.layout.pageContent(nPage, "contentArea").item(0), "mm") * 100) / 100, // height of the content area of the target page
	oContentH, oContentsH = 0, i, oNode, // variables
	nSpacerH = 0.0001; // defaul spacer height

// Check all relevant subforms
for (i = 0; i < oContents.length; i += 1) {
	oNode = oContents.item(i); // reference
	// if references subform is in the list of the relevants
	if (aRelevantContents.some(function (name) {return name === oNode.name;}) ) {
		// check if it spans multiple pages, check where it starts and which index is has on the target page. Then get it's height
		if (xfa.layout.absPageSpan(oContents.item(i)) > 1) {
			nSpanPage = nPage - xfa.layout.absPage(oContents.item(i));
			oContentH = Math.round(xfa.layout.h(oContents.item(i), "mm", nSpanPage) * 100) / 100;
		// if it doesn't spans pages, get just it's height
		} else {
			oContentH = Math.round(xfa.layout.h(oContents.item(i), "mm") * 100) / 100;
		}
		// summarize all heights
		oContentsH += oContentH;
	}
}
// calculate the height the spacer needs on the target page
nSpacerH += (oContentAreaH - oContentsH);
// set the spacer height
oSpacer.h = nSpacerH + "mm";
// rerender the form
xfa.layout.relayout();

 

 

If this helps, mark this as correct answer.