Determining page size
Hi,
In my application I need to create, at runtime, some rectangles in the
summary band.
1) Is it possible to know how much is the remaining space on the page after
the body has printed even considering the space needed by the header and
footer band?
2) Can I force a new Page to be printed? For istance, if I fill the first
page whit rectangles and have some other remaining, how can I tell the
report to go on printing in a new page?
In my application I need to create, at runtime, some rectangles in the
summary band.
1) Is it possible to know how much is the remaining space on the page after
the body has printed even considering the space needed by the header and
footer band?
2) Can I force a new Page to be printed? For istance, if I fill the first
page whit rectangles and have some other remaining, how can I tell the
report to go on printing in a new page?
This discussion has been closed.
Comments
a) Create a variable that you reset at the beginning of every page in the
report's OnStartPage event,
Initialize the value of the variable to the height of the header if
there is one.
c) On the BeforePrint event of the detail band add ppDetailBand1.Height to
the total of the variable.
d) On the OnEndPage event of the report add the height of the footer.
The sum in contained in the variable will be the total amount of space
taken up by the header, footer, and detail
bands on the page. Subtract that from the height of the page taking
into acount top and bottom margin to see if there
is space left on the page.
To draw a rectangle in the remaining space you can create a
TppDrawShape draw command in the OnEndPage event.
To add the draw command to the page by making the following assignment:
Shape.Page := Report.Engine.Page;
See the following demo for an example which creates lines to fill the
remaining space on a page. You can modify this example to draw a single
rectangle after the summary band prints.
www.digital-metaphors.com/tips/FillPageWithLines.zip
2 ) You can force a page break by doing the following:
Solution 1:
Define a Group that starts on a new page when
it breaks. Then use the Group.OnGetBreakValue
event to control the timing of the break.
1. From the Report Designer, select Report | Groups
to access the Group dialog.
2. Define a group based upon a static component,
such as a Label or Variable. Click the
Start new page checkbox. Close the dialog.
3. Using the object inspector's drop down list,
find and select the TppGroup object.
4. Create an event-handler for the Group's
OnGetBreakValue event.
5. Add code to set the break value.
procedure Form1.Group1OnGetBreakValue(Sender: TObject; var aBreakValue:
String);
begin
if condition then
aBreakValue := 'Some Value';
end;
Solution 2:
1. Place a subreport at the point where you might want a page break.
2. Remove its summary band and reduce the height of its detail and
title bands to zero.
By programmatically setting the title band's NewPage property you can
conditionally force a page break. Note that everything after the
subreport that is in the same band with it will need to
ShiftRelativeTo the subreport.
--
Cheers,
Alexander Kramnik
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com