on 2014 May 13 1:41 PM
Hi experts,
I required your urgent help for my development. I made a adobe form for customer ledger. Form is divided in 3 parts as shown in below image:
Header sub form will print on each page if form is more than one page. Then Body will grow to multiple page according data. Next is footer, it will print on last page (either last page is 1st or 4th page) positioned bottom. The problem is that in some situation. Like it prints Header, then prints body sub-form for open item. It grow according data. suppose that open item end on second page then footer should be placed on second page at bottom aligned. Footer sub-form is 2 inches( or 10-12 rows) in height. It should be checked that after end of body subform how much space is available. if there enough space for footer to be print then footer will print on same page other wise it will create one more page, at top of that page will print header sub-form and then at bottom aligned footer sub-form (there would be blank space between header and footer).
How to do that. Your help would be appreciate.
Please reply asap.
Thanks and Regards
Piyush Kumar
Request clarification before answering.
Hello Piyush,
Each row in the table will occupy a single line or will it occupy multiple lines also??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Piyush,
I will take a simple example. Let us consider that if you stretch the content area till the end, then maximum of 12 rows will occupy in a single page.
For now, let us consider that only a maximum of 12 rows will fit in a single page. I know the footer mentioned by you in the question is 10-12 rows in height. But let us move in a simple way.
First you have to check that how many rows are equivalent to 1 footer. For now, let us consider that only a maximum of 12 rows will fit in a single page. And the Footer is exactly 2 rows in height.
Now you need 2 master pages.
1st - master page---> Overlap the Footer on the Content area.
2nd - master page---> Create a new page with footer at the bottom.
Let us look at some of the scenarios below. This is very important because our next design is very much based on this.
1) 2 rows are equivalent to 1 footer. So 12 – 2 = 10 rows. So if there are less than or equal to 10 rows, then only 1 page will be printed.
2) If there are 12 rows, then 2 pages will be printed. 12 rows in 1st page and only the header and footer in 2nd page.
3) If there are 24 rows, then 3 pages will be printed. 12 rows in 1st page, next 12 in 2nd page, and only the header and footer in 3rd page.
4) If there are 36 rows, then 4 pages will be printed. 12 rows in 1st page, next 12 in 2nd page, next 12 in 3rd page and only the header and footer in 4th page.
From point 2,3 and 4 we can conclude that the new master page will be triggered when the number of rows in the table is greater than 10 OR when the number of rows in the table is exactly divisible by 12.
5) If there are 11 rows, then 2 pages will be printed. 11 rows in 1st page and only the header and footer in 2nd page.
6) If there are 23 records, then 3 pages will be printed.12 rows in 1st page, 11 in 2nd page, and only the header and footer in 3rd page.
7) If there are 35 records, then 4 pages will be printed.12 rows in 1st page, 12 in 2nd page, 11 in 3rd page and only the header and footer in 4th page.
From point 6 and 7, we can conclude that the new master page will also be triggered when the number of rows divided by 12 gives the remainder of 11. i.e number of rows % 12 should be 11.
6) If there are 15 rows, then 2 pages will be printed. 12 rows in 1st page, and the header, the rest of the 3 rows and footer in 2nd page.
7) If there are 36 rows, then 4 pages will be printed. 12 rows in 1st page, 12 in 2nd page, 12 in 3rd page and only the header and footer in 4th page.
So if you look at the pattern here, a new page with only the header and footer should be triggered only when the number of rows in the table is greater than 10 and either the number of rows in the table is exactly divisible by 12 or number of rows % 12 should be 11. i.e By using Modulus Operation, number of rows % 12 should give you zero or number of rows % 12 should give 11. In rest of the cases, only the 1st master page will be used.
Case 1 - If the rows and the footer comes in same page.
Now you have to take care that the footer should always be bottom aligned in the last page of 1st master page.. So for this you have to design the footer in the 1st master page. So overlap the Footer on the Content area. Later we will see how to show the footer only once in the last page.
Case 2 - If the rows end exactly or almost at the end of content area with no space available for a footer in 1st master page.
That's why you have to create new master page (Master Page 2) and then design the footer (bottom aligned) in this page. Now create a dummy sub form in the design view of the Page2. If you don't create a dummy sub form, then the 2nd page will never trigger. This is the key to triggering the 2nd master page.
How to determine if it is a Case 1 or Case 2 ??
2 rows are equivalent to 1 footer.
So 12 – 2 = 10 rows.
So Case 2 will only occur if number of rows is greater than 10 and if the total number of rows is exactly divisible by 12 or number of rows % 12 should give 11.
Now in the driver program, determine the number of rows in the table. Then set the flag if the CASE 2 is occurring.
So to determine whether it is CASE1 or CASE2, write the below code in driver program.
DATA: flag TYPE flag,
num TYPE i.
DESCRIBE li_tab LINES num.
IF ( num GT 10 AND ( num MOD 12 = 0 OR num MOD 12 = 11 )).
Flag = ‘X’.
ENDIF.
If FLAG contains blank, it is Case 1.
If FLAG contains “X”, it is Case 2.
Preventing Conflicts between Case 1 and Case 2
If Flag contains Blank, then it’s a first case. So footer from 1st Master page will appear only at the end of 1st master page. So you have to always hide the entire 2nd master page.
If Flag contains “X”, then it’s a second case. So footer from 2nd Master page will appear. So in this case you have to always hide the Footer of 1st master page.
For Case 1 - Write the below JavaScript code in the Ready Layout event of Footer sub form of 1st Master Page
// If CASE 2, then hide the footer of 1st master page
If ( data.FLAG.rawvalue != null )
{
This.presence = “hidden”;
}
Else
// If CASE 1, then show the footer only at the end of 1st master page
{
If ( this.rawValue = xfa.layout.page(this) != xfa.layout.pageCount() )
{
This.presence = “hidden”;
}
}
What the above JavaScript basically does is that, it will check if it is case 2. If yes, it will hide the footer of 1st master page. Else it will check if it is case 1. If yes, it will show the footer only in last page of 1st master page.
For Case 2 - No need to write the JavaScript on Footer sub form of 2nd Master Page. Because anyways if FLAG is blank, we will hide the entire 2nd Master Page
Drag the FLAG variable in the layout under data node. Write the JavaScript on Dummy sub form in Initialize event as below.
// If FLAG is empty, then hide entire 2nd master page
If ( data.FLAG.rawvalue == null )
{
This.presence = “hidden”;
}
Note: The main idea over here is to get the exact height of the footer equivalent to number of rows. As you said that the footer is 10-12 rows in height, I would like to mention that please calculate the exact value of Footer. Either it should be 10 rows height or it should be 12 rows but not both. I have taken a simple example here. I hope it will be almost same in your case too. Just the numbers might be different. I know it is difficult initially but its a one time activity. If you do the calculations correctly first time, it will make your life easier. Hope my solution will help you.
Hi Nitin,
Pavan told that put the dummy subform in design view and write this script on that dummy subform in his explanation. I did the same.
Problem:- I executed the program, footer and header are able to fit on first page with table data (table has 6 lines), so program must create only one page with header, table data and footer, but program is creating also one more page (second page in this case) with header and footer subform, while second page must be hidden.
what is wrong?
Regards
Piyush
Well, it should ideally go to 2nd master page only when it overflows data.
I think page structuring is an issue here.
Your page structure should be -
Master page1
- Body Page (In the overflow condition you can mention Master page 2, so then when data overflow then it should use master page 2)
Master Page2
I think you have put in master page2 under Master page 1 itself or something like that.
Thank,
Nitin
Hello Piyush,
You have to write this script on Design view of Page 2 because this sub form will be in design view itself and not in master page. The reason I told to put in design view is if you hide this sub form, the whole instance of Page 2 will not appear at all. So you will not get a blank page.
FLAG will be blank only if it is a CASE 1. So if this sub form is hidden successfully, then there will be nothing left to be shown in Content area of Page 2. So the 2nd Page which you designed will not appear at all in the PDF output.
Hi Prabhu,
Thanks for your help. I wanted solution like that. I did the same as above, but there is a problem. Table data is has 5 lines. So it should generate only one page with header--body(table)---Footer. But it is creating 2 pages. First page contains Header--Body(Table)---Footer and second page contains Header and footer.
Why is it creating additional page?
Regards
Piyush
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.