Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Put lines at the bottom of the last page.  (Read 20100 times)
Paul M.
Posts: 31


« on: April 14, 2014, 12:58:27 pm »

Hi,

I am looking for suggestions on how to print lines of text(max 10 lines) at the very bottom of the last page.
In old legacy reports all I had to do was:
 
FOR counter = LINENO TO 60 (70 line page - X (no. in lines trailer e.g. 10))
       SKIP 1 LINE
END FOR                             
PRINT trailer lines.

Can I do this in GRW?

Using studio 2.50.

Thanks for any assistance.
Alex G.
Four Js
Posts: 155


« Reply #1 on: April 14, 2014, 02:31:23 pm »

Hi,
>I am looking for suggestions on how to print lines of text(max 10 lines) at the very bottom of the last page.
>..
>Can I do this in GRW?
yes, we call that a "last page footer" and the following pattern can be applied for that:
First make sure that you can print a box whose size is minimal (just encloses the content) on the last page after the last item of report data.
This would typically be at the position of the last child of the page root.
Then you set "Y" for this box to "max" and "Anchor Y" to "1" which shifts the box to be bottom of the page
If you don't have page footers in your report then you are done at this point.
Otherwise you need to set the option "Hide Page Footer on Last Page" to prevent the box from painting on top of the standard footer.
In addition to that you need to look if the box (The "last page footer") is taller than the standard footer. If yes then insert an empty box before your "last page footer" whose height equals or is greater than the difference in height between the "last page footer" and the standard footer.
A similar case has been discussed in the thread "Last Page Footer" (https://4js.com/fjs_forum/index.php?topic=803.0)
The upcoming version will have a "Last Page Footer" section specifically for this problem.
Regards,
Alex
Paul M.
Posts: 31


« Reply #2 on: April 14, 2014, 03:22:53 pm »

Alex,

Thanks for your reply. I did see the other post but didn't read your reply properly and so of course it didn't work .
I think I have it correct this time and now the trailer comes out at the bottom exactly as required but the detail lines are running into it and getting overwritten(see screen shot attached).

I am using a Table to print out the main bulk of the details(report structure screenshot).

Have I set it up correctly as I have never used tables before.

Regards


* Screenshot - Mon-14Apr14@1412.png (23.4 KB, 595x204 - viewed 2466 times.)

* Report-Structure.png (50.14 KB, 706x649 - viewed 2428 times.)
Alex G.
Four Js
Posts: 155


« Reply #3 on: April 14, 2014, 03:39:22 pm »

Sorry, my mistake.
>In addition to that you need to look if the box (The "last page footer") is taller than the standard footer. If yes then insert an empty box >before your "last page footer" whose height equals or is greater than the difference in height between the "last page footer" and the >standard footer.
I wrote that this applies only if you have a standard footer but that is incorrect. Put a spacer that is just as high or higher than the "last page footer" box as previous sibling to the "last page footer" box and that should fix it.
The reason is, that items who have "Y" set are considered "self placing" (like floating images) and hence they are not considered as consuming space. That is why the footer (who has Y="max") overlaps the table.
Regards,
Alex
Alex G.
Four Js
Posts: 155


« Reply #4 on: April 14, 2014, 03:51:45 pm »

Hi,
>Have I set it up correctly as I have never used tables before
I forgot to address this in my previous reply.
Yes, it looks just fine. You have a FOR loop in "OnEveryRow" but I suppose that this is empty. I am asking because when adding dynamic columns the number of cells has to match the number of column definitions so that one would also expect a FOR for the COLDEFs.
Regards,
Alex
Paul M.
Posts: 31


« Reply #5 on: April 14, 2014, 04:27:41 pm »

Alex,

Thanks for your time.

I understand what you mean about items that have Y set as being floating. I have put a spacer before it and have set the y-size to
Code
  1. length("M")*{no_lines}
with the no_lines being the amount of lines in my trailer and it seems to work, I saw this in another posting where somebody wanted to replicate the NEED X LINES and this was suggested.

Have I got the right idea? I ask as I have many more reports to convert that do the same type of thing with trailer lines and I want to understand the GRW a bit more and get it right first time.

Regards,
 


* Screenshot - Mon-14Apr14@1516.png (49.09 KB, 945x874 - viewed 2423 times.)
Alex G.
Four Js
Posts: 155


« Reply #6 on: April 14, 2014, 04:47:53 pm »

Hi,
>Have I got the right idea? I ask as I have many more reports to convert that do the same type of thing with trailer lines and I want to understand the GRW a bit more and get it right first time.
Yes, absolutely. If the spacer uses the same font as the footer then an expression like length("M")*{lines} will do the trick.
Regards,
Alex
Paul M.
Posts: 31


« Reply #7 on: April 14, 2014, 04:51:19 pm »

Alex,

Yes same font, so I will go with this.

Looking forward to "Last Page Footer" section.

Thanks for your time.

Regards,
Reuben B.
Four Js
Posts: 1126


« Reply #8 on: April 15, 2014, 12:02:00 am »

Another possible approach for the Y-size property of the Spacer is an expression like

rest>3cm?0cm:rest

where 3cm is the Y-size property of the Trailer (Footer) element.   (and this trailer element also has Y=max, AnchorY=1)

What this is doing is saying the Trailer element needs 3cm to draw at the bottom of the page.  Just before it is drawn, check how much space is left (the value of rest).  If there is enough room (rest>3cm), then we don't need to draw anything (Spacer's Y-size=0cm), if there isn't enough room (ie rest <=3cm), then draw spacer so it takes up rest of page (Spacer's Y-size=rest), and thus the spacer takes up rest of page, and trailer is drawn on the next page.

I've used 3cm, you could use length("M")*no_of_lines, although I'm wary of using length,width too much because of the "If it uses the same font"disclaimer.  (Its not just font-name that has to be the same but ALL the font characteristics).

An interesting issue with these last page footers is how to avoid orphan footers.  By that I mean a footer with no detail on the same page.  So rather than rendering the last few rows of detail on the second to last page, render them at the top of the last page.  I think the rest approach handles that if you move the spacer up into the OnEveryRow, and adjust the constant used in the rest comparison e.g. rest>4cm?0cm:rest (but keep the size of the trailer the same 3cm).  Not sure if that will work in conjunction with a table.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines