Working out when to page break

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Working out when to page break

Postby AndrewKennard » Mon Jun 23, 2008 3:18 pm

hello

I am printing "columns" of data using VPE Write

Currently when it gets to the bootom of the page I am getting a new page for each column for the 'next row' and then when it gets to the end of that it then carries on 'properly'

Now I can see each column is tripping the auto page break

But if I turn this off there does not seem to be an 'easy' way to work out when to page break ?

Do I have to do something like this ?

If ((VpeGet(hDoc, VBOTTOM)+VpeGet(hDoc, VRENDERHEIGHT))> (VpeGetPageHeight(hDoc)-VpeGet(hDoc, VBOTTOMMARGIN))) Begin
Send New_Page
End

Thanks

Andrew
AndrewKennard
 
Posts: 4
Joined: Tue Jun 17, 2008 10:52 am

Postby IDEAL Software Support » Tue Jun 24, 2008 8:31 am

If AutoBreakMode is turned on, the first text object, which touches or exceeds the bottom margin will cause an automatic page break.

Therefore your test is ok, except that you should use >= instead of the > operator. I would recommend to eliminate the many function calls by storing some values in variables, i.e.:

At the beginning of your function:
Code: Select all
nRenderHeight = VpeGet(hDoc, VRENDERHEIGHT)
nBottomMargin = VpeGetPageHeight(hDoc) - VpeGet(hDoc, VBOTTOMMARGIN)


And later in your code it will read:
Code: Select all
if (VpeGet(hDoc, VBOTTOM) + nRenderHeight >= nBottomMargin) ...
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby Patrick » Fri Mar 13, 2009 4:07 pm

Same things happening to me - my 2 page report is turning into a 300+ page report w one word on each page - all these lines print 3 cm from top.

Can't I use in the #VPE.AfterAutoPageBreak event:

#VPE.SetDefOutRect LEFT(1) TOP(3) RIGHT(20) BOTTOM(20)

to set the bottom margin on a 8.5 x 11" paper? It doesn't seem to work? The above event fires 300+ times? What am I doing wrong?

My Visual Lansa environment and the Active X control does not have method VpeGet or any kind of RenderHeight method? (Edit: ok found the RenderHeight property)

I've also tried: #vpe.nBottomMargin = 20 in the AfterAutoPageBreak event - w no success.

Thank you,
Pat
Last edited by Patrick on Fri Mar 13, 2009 4:40 pm, edited 1 time in total.
Patrick
 
Posts: 23
Joined: Thu Mar 12, 2009 5:44 pm

Postby Patrick » Fri Mar 13, 2009 4:39 pm

OK, trying different things.

When I use: #VPE.SetDefOutRect LEFT(1) TOP( 8 ) RIGHT(13) BOTTOM(13)

The subsequent pages print 8 cm from the top, but seems to ignore the Right and Bottom settings? It prints out to ~ 19 cm to the right. SetOutRect does the same thing.

PageFormat is set to -2 (8.5 x 11")

ok, Second page prints one word at 2, 2, then all other pages go to the 8 cm down the page.

If I do not handle the AfterPageBreak event, all subsequent pages print 2cm from top only, across the entire page.

What am I missing?

Thank you,
Pat
Patrick
 
Posts: 23
Joined: Thu Mar 12, 2009 5:44 pm

Postby IDEAL Software Support » Fri Mar 13, 2009 6:15 pm

Sorry, but I am really confused by your messages and I can't see exactly what you are doing.

If you want to create a table, i.e. if you have multiple columns or cells in a single row, you need to turn automatic text break off. Instead perform the page breaks yourself in the moment when any of your cells reaches the bottom margin.

the Active X control does not have method VpeGet


VpeGet() is only for the DLL. All other components (ActiveX, .NET, VCL, etc.) have a much more elegant mechanism by providing the values as properties (e.g. nLeft, nRight, nTop, nBottom, etc.).

I recommend that you read the help file titled "Programmer's Manual". In the chapter "Programming Techniques" you will find detailed information about using the layout engine of VPE.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby Patrick » Fri Mar 13, 2009 7:55 pm

>> Sorry, but I am really confused by your messages

I have that effect on people sometimes! lol

Yes, I'm trying to print a table w 7 columns. I thought I could get VPE to control the overflow (PageBreaks) onto subsequent pages thru the event: AfterAutoPageBreak and the SetDefOutRect property?

I will turn off AutoTextBreak and handle the page breaks myself.

Thanks for your help,
Pat
Patrick
 
Posts: 23
Joined: Thu Mar 12, 2009 5:44 pm

Postby IDEAL Software Support » Sat Mar 14, 2009 2:08 pm

You could use the AutoPageBreak mechanism to break cells, but it makes things more complicated - you would need to switch from the newly generated pages back to the original page to insert the remaining cells (not in the AutoPageBreak event, but after you inserted the cell and control has returned to your program). Mainly the AutoPageBreak is intended to break large text objects automatically over multiple pages.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 7 guests

cron