Go Premium for a chance to win a PS4. Enter to Win


Any way to put printing Page Breaks in html?

Posted on 1998-10-22
Medium Priority
Last Modified: 2010-04-09
I am converting a word .doc to html.  It will probably be printed by the user, and I'd like to force some page breaks when its printed.
Is there any way to do this in HTML?
Question by:clay111296
  • 2
  • 2

Expert Comment

ID: 1838960
There is an option for IE 4.0x:

<DIV STYLE="page-break-before:always;">&nbsp</DIV>


<DIV STYLE="page-break-after:always;">&nbsp</DIV>

This is part of CSS 2.0.  We should see it implemented in the future with Netscape because this standard has been approved by the W3C.

Author Comment

ID: 1838961
Thanks for the tip. I suspected as much. I'll leave the question open, though.  If enough people do that, eventually the question will be worth 1,000s of points and perhaps someone will develop a solution :-).

BTW, I did find a printer driver program that allows any browser to support page breaks.  
But that's a bit extreme.  Would be easier to put it in .doc format and include a link to the word reader program from M$
LVL 11

Accepted Solution

RoadWarrior earned 400 total points
ID: 1838962
clay, i have been thinking about this a lot recently and that printer driver program may be the only possible way to implement it properly. This is because, on a browser the user may select the base font size, the base style of font etc, even forcing the size with the font tag has different results on different systems, added to that, some people have crusty old 9 pin 120 dpi printers, some people have ultra mega super high quality 1200 dpi laser printers. implementing of page breaks within html means virtually writing a browser that "runs" on a printer. The number of combinations of peoples browser preferences, default display modes, printers and every other thing against us is staggering. There needs to be some standard in there, and it is neither in html which as a "feature" can be displayed pretty well any old how at the user end, or the browsers or the printers or the computer systems of this world. Print formatting needs a high degree of document layout and presentation rigidity that does not exist in html, and may never do. It is not as simple as embedding the formfeed escape code in the document, that would only work if the printing was straight text in the printers own fonts, hardly used, guess you could tell people to print "draft mode" to get the right formatting, almost everything prints in graphics mode though, some people may have their fonts set up on their 1600x1400 screen such that a single sentence overruns a page on their 120x120 dpi printer when printing from a browser.

just off the top of my head here are some of the things that need to be supported in html and hence browsers to allow print formatting..
specifying of point size of type, of style of type including absolute width and leading of characters (failing that a few absolutely standard, same on everything fonts)
specifying line spacing. absolute line spacing in points not relative.
and hard page breaks of course.

i think the best current solution, is to make the file in adobe acrobat .pdf format and provide a link to download the viewer or the plugin, which a lot of people have already, probably more than have microsloth word or a viewer, since there are acrobat viewers for far more platforms than there are word viewers, and the adobe format has been designed to be so rigid as to give the same or substantially similar results on any capable computer/printer combination.

There is one and only one getaround that i can think of and it involves assumption that the user is printing on A4 paper of the size 8.5 ins by 11 ins. We also have to assume margins, at a guess most popular might be around 1/2 ins all round, so count on 7.5x10, be as well to point this out to the prospective user/printer though. One makes an image per page either .gif or .jpg of the text to be printed, with the same aspect ratio as the a4 page, to get a fairly decent print quality one has to make the dpi at the print end about 300 so that is going to give us a huge image size of 2250 x 3000, displayed on the browser with the width property set to 100% i.e.

<img src="http://docimage.jpg" width=100%>

and have no other html on the page, no links, just the pages one after another, no spacing between them. This is going to be a huge download for anyone though.
Having said that, you can make things better by doing it as a 1bit gif, i.e. two colors black and white only, any images dithered, just tried a fairly simple one at that size and it saved  out to a file only 15k, (not much text in it though, a "full" image might not compress so well) BUT that takes 800k unpacked! go more than a few pages per html page and a lot of systems will not cope. So that will work on standard browsers, I am sure someone will correct me if i am wrong but i think at least netscape 2 upward and internet explorer 3 upward *smile* provided you tell the user the paper size and margins to set.

The Future.

Microsoft are producing word, excel etc applications that can save as a web page and publish AND retain original document formatting hidden beneath the HTML so at some time in the future Internet Explorer might take advantage of such formatting to print, but not as yet.


Road Warrior.
LVL 11

Expert Comment

ID: 1838963
there is also another assumption on that image file method, for it to work, the users printer must be set to a "square" resolution i think, i.e 240x240 or 600x600, not 240x200 or 600x300 or anything like that, though i presume in most cases the driver and browser should correct for that, but having had some wierd prints from my printer when set to 320x240, i would not count on it.
*smiling* also it would be important to tell people to print from the browser, if they save the images separately and print them with something else, then the sizing is at the mercy of their viewer app, that is why we are setting the image width to 100% with html *smile*


Road Warrior.

Author Comment

ID: 1838964
Not a complete solution, but merits a grade.  Thanks for the input.  Giving a 'C' only because it doesn't actually solve the problem, but, rather, reveals no solution exists.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question