Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!

2 master pages with table data flow

Avatar

Former Community Member

Hi,

  My form got 2 master pages. Each master page will display atleast once in the output preview. First page displays table data which may or may not flow to the second page depending on the no.of records. But, the form will show both the master pages in pdf preview( even if the second master page is empty).

  Now, I have a field in the both the master pages which will show the total amount. Total amount field will have a value which should be displayed in the first page if the data doesn't flow to the second page. The total should display in the second page if data flows to the second page. Where can I write the condition and how will I know whether the form is flowing to the second page or not? I cannot write based on the pagecount because the output will always contain 2 pages.

How will I know my table is flowing to the next page or not so that I will write my logic based on it.

Thanks,

kc

6 Replies

Avatar

Former Community Member

If there is only enough data in the table to appear on one page why woudl you show the second page? If you use this logic you can test the page that you are on and know which calc to run.

Paul

Avatar

Former Community Member

That's the client requirement. They have different headers for each page and they want to display the second page with header even if it doesn't have any data.

So, my pagecount will be alwasy 2 irrespective of table data. How will I know whether the data is flowing to second page or got limited to just the first page?

Thanks,

k.c

Avatar

Former Community Member

You have a fixed page size so you know how many rows it takes to fill the page. You can get a coount of instances form the instanceManager.count and if it is more than the number to fill the page then you will know you are on the 2nd page.

Paul

Avatar

Former Community Member

Hi Paul,

  I thought of this solution. But the problem is it's multi-level table which got some inconsitent no.of records for each level.

For every record with its sublevel records, I have to present some blank space for the next record. And we donot know in advance how many sublevel records will be there for each main record. So, I could not predict the exact layout space required for the first page just based on the count of records.

Do we have any events that trigger or in some way we can find that the table got flowed to the next page?

Your valuable inputs will be really helpful.

Thanks,

kc

Avatar

Former Community Member

On the initialize event of the rirst field in the row you can use this command:

xfa.layout.page(this

)

This command will return to you the page number that "this" object is in. "this" refers to the current object. I do not remember if the page numbers are 0 based or 1 based  but when you get the correct return you can do what you need to do.

Paul

Avatar

Former Community Member

Hello Dude,

Try to find out the field of the table is in which page. If it is in page 2 so u can print the amount there.

try this script

for(var i = 0 ; i < xfa.host.numPages ; i++)  // loop uoto total number of pages

{

  var oFields = xfa.layout.pageContent(i, "field"); 

  totalfields   =  oFields.length;                    // gives the number of fields in a page

   flag=1;      

  for (var nNodeCount = 0; nNodeCount < z; nNodeCount++)  // loop through the fields

     {  

         if (oFields.item(nNodeCount).name == "find your table field")   // Here find for that field if it works print maount in that page

Good Luck

Regards,

RAkesh