By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 2,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

Force Page-break when printing

P: n/a
CJM
What is the best way to force a page break when printing from a browser?

A page in my application generates a series of tables which are usually less
than will fit on a page of A4. Ideally I want to introduce a page break
between each table when printing.

I'm not sure what options I have available. I know there is some support in
CSS but I'm no sure on the details or effectiveness.

Thanks in advance...

Chris

--
cj*******@REMOVEMEyahoo.co.uk
[remove the obvious bits]
Feb 2 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Thu, 2 Feb 2006 16:44:01 -0000 from CJM <cjmnew04
@REMOVEMEyahoo.co.uk>:
What is the best way to force a page break when printing from a browser?
You'll hear a chorus of people telling you you can't "force"
anything. They're right: the best you can do is _suggest_.
A page in my application generates a series of tables which are usually less
than will fit on a page of A4.
A4? What's A4? Yes, _I_ know what A4 is, but browsers can print to
many different paper sizes. You should not, repeat _not_, try to set
up your pages to print to any particular paper size if you're putting
them on the _World_ Wide Web.
Ideally I want to introduce a page break
between each table when printing.
I suppose you mean "between tables". That's a bad idea -- see above.
Any decent browser will try to keep a table on the same page if it
can do it. You can help browsers by putting your header row (if any)
in <thead>...</thead> and similarly for your footer row. Then if the
table is too big for a page -- and remember that you _do_not_know_
the page size -- a good browser will repeat the header and footer as
needed.
I'm not sure what options I have available. I know there is some support in
CSS but I'm no sure on the details or effectiveness.


Look in the CSS spec for page-break-before. Browser support is less
than perfect, but as I explained above you should not be using this
anyway for the application you mention.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 2 '06 #2

P: n/a
Followup-to set: comp.infosystems.www.authoring.stylesheets

CJM wrote :
What is the best way to force a page break when printing from a browser?

A page in my application generates a series of tables which are usually less
than will fit on a page of A4. Ideally I want to introduce a page break
between each table when printing.

table
{
page-break-before: always;
page-break-inside: avoid;
}

http://www.w3.org/TR/CSS21/page.html...e-break-before

http://www.w3.org/TR/CSS21/page.html...e-break-inside

I'm not sure what options I have available. I know there is some support in
CSS but I'm no sure on the details or effectiveness.


It's not widely or well implemented. Except maybe Opera 8+

Followup-to set: comp.infosystems.www.authoring.stylesheets

Gérard
--
remove blah to email me
Feb 2 '06 #3

P: n/a
CJM
The only HTML suggestion I've seen so far was to add a host of <br> tags to
approximate a page... erm... no, thanks.

I've successfully implemented a fixed sized table (32 rows) with
page-break-before:always and it works pretty well.

Stan, I *can* guarrantee A4 size... this is for an intranet application, so
I do know what my target users will be using. However, I take your point
about these issues when dealing with the WWW,

I'd read about the woeful support for page-break-inside:avoid, so I didnt
bother investigating this avenue, bearing mind that I already had discovered
a reasonable solution.

Thanks

Chris
Feb 3 '06 #4

P: n/a
Fri, 3 Feb 2006 16:00:56 -0000 from CJM <cjmnew04
@REMOVEMEyahoo.co.uk>:
Stan, I *can* guarrantee A4 size... this is for an intranet application, so
I do know what my target users will be using.


Oh -- it might have been nice if you'd disclosed that up front when
asking your question on a World Wide Web forum.

But if you're concerned about printing, the right answer is to
distribute something that is page oriented, such as PDF. HTML ain't
it.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 3 '06 #5

P: n/a
JRS: In article <MP************************@news.individual.net> , dated
Fri, 3 Feb 2006 11:46:11 remote, seen in news:comp.infosystems.www.autho
ring.html, Stan Brown <th************@fastmail.fm> posted :
Fri, 3 Feb 2006 16:00:56 -0000 from CJM <cjmnew04
@REMOVEMEyahoo.co.uk>:
Stan, I *can* guarrantee A4 size... this is for an intranet application, so
I do know what my target users will be using.


Oh -- it might have been nice if you'd disclosed that up front when
asking your question on a World Wide Web forum.


He posts with a UK address; it's obvious to any non-American that,
world-wide, A4 is much more common than the similar Imperial size.

You people really should realise, and then remember, that in most
respects your country is in a minority of about 1.5 to (N-1.5), where
there are N countries in the world.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Delphi 3 Turnpike 4 ©
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.html> news:borland.* Guidelines
Feb 4 '06 #6

P: n/a
Sat, 4 Feb 2006 19:14:29 +0000 from Dr John Stockton
<jr*@merlyn.demon.co.uk>:
JRS: In article <MP************************@news.individual.net> , dated
Fri, 3 Feb 2006 11:46:11 remote, seen in news:comp.infosystems.www.autho
ring.html, Stan Brown <th************@fastmail.fm> posted :
Fri, 3 Feb 2006 16:00:56 -0000 from CJM <cjmnew04
@REMOVEMEyahoo.co.uk>:
Stan, I *can* guarrantee A4 size... this is for an intranet application, so
I do know what my target users will be using.


Oh -- it might have been nice if you'd disclosed that up front when
asking your question on a World Wide Web forum.


He posts with a UK address; it's obvious to any non-American that,
world-wide, A4 is much more common than the similar Imperial size.


Well, of course. But that's completely irrelevant to my point, as
would be obvious if you hadn't snipped essential context.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 5 '06 #7

P: n/a
JRS: In article <MP************************@news.individual.net> , dated
Sat, 4 Feb 2006 20:16:17 remote, seen in news:comp.infosystems.www.autho
ring.html, Stan Brown <th************@fastmail.fm> posted :
Sat, 4 Feb 2006 19:14:29 +0000 from Dr John Stockton
<jr*@merlyn.demon.co.uk>:
JRS: In article <MP************************@news.individual.net> , dated
Fri, 3 Feb 2006 11:46:11 remote, seen in news:comp.infosystems.www.autho
ring.html, Stan Brown <th************@fastmail.fm> posted :
>Fri, 3 Feb 2006 16:00:56 -0000 from CJM <cjmnew04
>@REMOVEMEyahoo.co.uk>:
>> Stan, I *can* guarrantee A4 size... this is for an intranet application, so
>> I do know what my target users will be using.
>
>Oh -- it might have been nice if you'd disclosed that up front when
>asking your question on a World Wide Web forum.


He posts with a UK address; it's obvious to any non-American that,
world-wide, A4 is much more common than the similar Imperial size.


Well, of course. But that's completely irrelevant to my point, as
would be obvious if you hadn't snipped essential context.


If I had wished to comment on the other part of your article, I would
have quoted from it. If the part I quoted was not thought worth
considering, then it should not have been posted.

On the World-Wide Web, the use of World Standard measurements is what
should be presumed. Few non-Americans choose to use Imperial sizes for
anything technical nowadays. World standards are metric, except in
fields where consistency is more important than rationality.

It's amusing, though, that the two most commonly-uses types of paper
here in the UK, though probably metric, don't seem to be A/B/C sizes.

--
© John Stockton, Surrey, UK. *@merlyn.demon.co.uk / ??*********@physics.org ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Correct <= 4-line sig. separator as above, a line precisely "-- " (SoRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)
Feb 5 '06 #8

P: n/a
CJM

"Stan Brown" <th************@fastmail.fm> wrote in message
news:MP************************@news.individual.ne t...
Oh -- it might have been nice if you'd disclosed that up front when
asking your question on a World Wide Web forum.

If it was relevant to my question, I would have stated it. It wasn't - you
suggest the point at which you want a page-break in the pages and it works
the same whether or not the pages are accessible from the WWW or not.

The issue about unknown page sizes are equally relevant on intranets if you
can't guarrantee that the user will use a particular page size. In my case I
know that all my users use A4.
But if you're concerned about printing, the right answer is to
distribute something that is page oriented, such as PDF. HTML ain't
it.


Funnily enough, the PDF component we have renders an ASP page as a PDF. Page
breaking is controlled the same way in the PDF engine as it is on paper -
that is, I'd use this same CSS technique to inject breaks.
Feb 6 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.