Page Break Script (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


BeamMeUp -> Page Break Script (6/13/2002 10:55:17)

Does anyone know if it is possible to have a script automatically create page breaks in a long html document that contains tables and photos, so that when printing one page or the entire document, the photos and/or a line of text is not split in two.

I know how to manually insert the page-break tag but this will need to generate correct printing pages based on what is selected, or the entire document.





Mojo -> RE: Page Break Script (6/13/2002 11:11:36)

The following code will force a pagebreak in CSS2:

<P style="page-break-after: always">

You may want to look into this attribute because there is more to it...








rdouglass -> RE: Page Break Script (6/13/2002 13:45:09)

Yes it is possible. I do it on a form results for a census form that gets emailed. Each page holds 13 clients. The relevant portion of the page I use looks something like:

'-------------------- Build pages recursively
FOR pageNumber = 1 to totalPages

'-------------------- Display user info on each page
strText = strText & "<p CLASS='page' align='center> </p>" & vbcrlf & "<p align='right'><font face='Arial' size='2'>Page # " & pageNumber & "</font></p>" & vbcrlf
strText = strText & "<p align='center'><font face='Arial' size='4'>Group Census<br>Confidential List of All Eligible Employees</font></p>" & vbcrlf
strText = strText & userInfoTable & "<br>"

'-------------------- Begin employee info table
strText = strText & "<div align='left'><table border='1' cellpadding='2' cellspacing='0' width='895' columns='10'>" & vbcrlf

'-------------------- Display table header
strText = strText & tableHeader

'-------------------- Build table of employees by retrieving array items
FOR e = 0 to 12
f = (((pageNumber - 1) * 13) + e)
IF f <= upper THEN
strText = strText & arrEmployees(f)
ELSE
END IF
NEXT
strText = strText & "</table></div>" & vbcrlf

'-------------------- Next page
NEXT


and I had a line like this in my <style> section:

p.page { page-break-before: always }

(I just break before instead of after for personal preference ) The full code of the page can be seen here:

http://www.clarkinsurance.com/cdonts_example.htm

but the whole page is primarily a CDONTS script to send HTML mail. It gets a little involved using arrays and such, but the code showing the recursive use of the page break is above.

Any help???

 




ahaynes106 -> RE: Page Break Script (8/10/2005 18:48:59)

quote:

<P style="page-break-after: always">


do you need anything else? I stuck that in my code where I wanted the page break to oocur, but nothing. It just printed past that point until the page filled up and overflowed to the next page.




ahaynes106 -> RE: Page Break Script (8/19/2005 13:15:35)

I found these on MozillaZine Forums. Finally, something that worked for me on Firefox and IE. Not sure why the others worked in IE but not Mozilla.

This works:
<p>
...
</p>
<br style="page-break-before: always;" clear="all" />

This works:
<div>
...
</div>
<p><br style="page-break-before: always;" clear="all" /></p>

And this works:
<div>
...
</div>
<br style="page-break-after: always;" clear="all" />




jaybee -> RE: Page Break Script (5/8/2008 7:14:14)

All sounds just Hunky Dory doesn't it. You stick in this little bit of code and Hey Presto! Problem solved.

Unfortunately, you haven't taken into account that different people have different printers with different gutters, margins, paper sizes and so on and so forth.

If you want to force page breaks you need to test on a load of different printers or your cleverly formatted instructions will be churning out half filled pages for some people.




jaybee -> RE: Page Break Script (5/8/2008 7:17:01)

quote:

ORIGINAL: ahaynes106

quote:

<P style="page-break-after: always">


do you need anything else? I stuck that in my code where I wanted the page break to oocur, but nothing. It just printed past that point until the page filled up and overflowed to the next page.


quote:

ORIGINAL: Mojo
You may want to look into this attribute because there is more to it...


It's CSS you need to read up on it.




d a v e -> RE: Page Break Script (5/8/2008 8:56:12)

you do have a print stylesheet don't you?!




rdouglass -> RE: Page Break Script (5/8/2008 8:57:38)

...jaybee answering 3 year old posts? Must be an imposter.....[:D]




d a v e -> RE: Page Break Script (5/8/2008 10:11:20)

dang - got me too! and the original post was in 2002!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125