Expand my Community achievements bar.

How to get a footer only on the last page.

Avatar

Former Community Member
Hello,



can you please give me any idea how to force LiveCycle ES to display any footer only on the last page of a dynamic form? I can write a short script which would check if the dynamically generated page of the report is the last one or not, but how can I do it in a Form design? If I create a footer on Master page, under a content area, then the place reserved for the footage will be generated on each page (it will be hidden because of the script condition), but not only on the last one.



Does anyone have any idea?

Thank you very much for any suggestions.



Best Regards,

Jan
4 Replies

Avatar

Level 1

Hi,

I have just started using livecycle designer and I have been trying to figure out the best way to do this also.  I came up with a possible solution.  On the masterpage I created a control (in my case a text field) called LetterFooter.  I set the 'presence' property to 'invisible' at design time.  Then in form's docReady event  (my form is named Letter) I put the following javascript:

var lastPage = xfa.layout.absPageCount()-1;
if(xfa.layout.absPageCount() >  1){
    xfa.resolveNode("Letter.#pageSet.Page1[" + lastPage + "].LetterFooter").presence = 'visible';
}
else{
    xfa.resolveNode("Letter.#pageSet.Page1.LetterFooter").presence = 'visible';
};

These controls will all be invisible by default and the code will set the control on the last page to visible.  If there is only one page then it does this using the else condition.

I am not entirely satisfied with doing it this way but I haven't seen anyone else with a suggestion nor found any good documentation on how to insert a footer only on the last page.

Adam

Avatar

Level 1

I wasn't satisfied with the first solution I came up with.  This was because it turned out the footer on my last page could actually be multiple footers and I am dealing with a dynamic form that has a merged data source.  I came up with a way to get the footer correctly at the bottom of the last page using a few extra objects and javascript.  My form is in a flow layout and can be 1 or more pages dynamically generated at the runtime.  I have it divided into subforms that can dynamically grow.  I have no idea what size they will be.  My footer can be 1 or many footers that needs to go on the last page so my previous solution will not work well for this since that soultion is a fixed size on the masterpage.

What I did was put my footer object, which is a text field that is bound to an XML node that can repeat 1 or more times, into a subform and placed that in the contentarea of the page.  Surrounding this I put my controls that help place the footer properly at the end of the documents last page.  So in a subform (name doesn't matter for subform) I placed a text object (text object named: spaceFooter) immediately above the footer subform.  And another text object (name doesn't matter for this text object) in a subform (subform named: spaceAfterFooter) immediatley below the footer.  Both of these text objects I set to be invisible and made them .01 inches in height, to take up no real visible space, and as wide as the content area.  The subforms were set to flowed layout and height property to auto fit.  Then I put the following code into a variable script and call it from the documents ready:layout event:

//code that is in the event
MyDoc::ready:layout - (JavaScript, server)
MyDocUtils.positionFooter();
//code that is in variable
MyDocUtils.#variables[0].LetterUtils - (JavaScript, server)
function positionFooter() {
// xfa.log.message(0,"Start positionFooter"); //sends message to log tab for debugging
  var subY=0;
  var contH=0;
  //get the subform that is placed directly after the footer to find out where on the page the footer originally ends
  var spaceAfterFooter = getObjectOnLastPage("subform", "spaceAfterFooter");
  subY= xfa.layout.y(spaceAfterFooter,"in");
  //find the content area height so we know all the space that is available on the page
  var contentArea = getObjectOnLastPage("contentArea", "#contentArea");
  contH= xfa.layout.h(contentArea,"in");
  //set the height of the object that is used for the "spacer"
  xfa.layout.relayout();
}

function  getObjectOnLastPage(objectType, name) {
  var page = xfa.layout.absPageCount() - 1;
  var objs = xfa.layout.pageContent(page, objectType);
  for (var i=0; i<objs.length; i++) {
      var som = objs.item(i).somExpression;
      if (som.indexOf(name) != -1){
        return objs.item(i);
      }
  }
  return null;
}

So what is happening is the form is first layed out and everything gets placed on the pages the way flow layout would place them.  I find out where the very last object on the last page is located, and get its Y position.  Then I find out what the total height of the content area is which is the total space I have to work with on the page.  By knowing these 2 things I can subtract the y positon from the height of the content area to find out what the amount of space is left at the very end of the page.  Then I take that space and set the height of the object that I have before the footer to that.  This causes the footer to be "bumped" down to the end after the relayout() method gets called.  And now the footer is in the proper place.

Avatar

Level 1

Sorry about the code format.  Tried multiple times to get it to look better but wasn't too successful using this message editor.

Avatar

Level 2

Hi there, I know this is an old post but I'm hoping someone can still help me with it. I am also trying to add a footer, but I only want it to appear on whatever ends up being the last page (I have a dynamic table that expands as text is being filled into it).  My footer has a logo and text, so I had put my footer in a subform on the master page and used the code below. 

 

var lastPage = xfa.layout.absPageCount()-1;
if(xfa.layout.absPageCount() >  1){
    xfa.resolveNode("Letter.#pageSet.Page1[" + lastPage + "].LetterFooter").presence = 'visible';
}
else{
    xfa.resolveNode("Letter.#pageSet.Page1.LetterFooter").presence = 'visible';
};

 

It seemed to work great, until my dynamic table content is filled in, and my table contents move to yet another page, and then the logo disappears. Shouldn't it still appear on the last page? Or am I doing something wrong? Any help would be greatly appreciated! My text is also overlapping on top of my logo when it appears as well. Any way of fixing that issue as well?

Any help would be greatly appreciated!

 

Tamara