Solved

Print Page Break - HTML Page Break

Posted on 2004-10-25
53,896 Views
Last Modified: 2011-08-18
Is there a way to put a character within HTML so when someone prints the HTML form/screen I can force a page break. I want to develop a new HTML form/screen for an employee to fill out, and when they print it the screen/form prints two separate pages. I want to be able to control where the 2nd page starts.
0
Question by:tomhoran
    7 Comments
     
    LVL 14

    Accepted Solution

    by:
    You need to use the CSS "page-break-before" or "page-break-after" properties.  Here's a working example:

    <html>
    <head>
    <style type='text/css'>
    @media print
    {
        .pagestart
        {
            page-break-before: always;
        }
    }
    </style>
    </head>
    <body>
    <p>This is on page 1.</p>
    <p class='pagestart'>This is on page 2.</p>
    </body>
    </html>
    0
     

    Author Comment

    by:tomhoran
    That's eay .. will that work in both IE and netscape .. anothers all browsers ?
    0
     
    LVL 14

    Expert Comment

    by:RichieHindle
    I tested it in IE6 and Firefox 1.0PR on XP.  I don't have older versions to try it with, but I'd be very surprised if it didn't work in IE5+ and Netscape 6+.
    0
     
    LVL 3

    Expert Comment

    by:nan1217
    I had a hard time getting those CSS properties to work and ended up using a PDF component to have ultimate control.  ABCPDF (abcpdf.com) can be used free if you link back to their site.  If you pay for a component, I like ASPPDF (asppdf.com).
    0
     
    LVL 14

    Expert Comment

    by:RichieHindle
    nan1217: Can you elaborate on 'a hard time'? Did you find that older browsers didn't support them, or were buggy, or that the properties didn't work with your content...?
    0
     
    LVL 3

    Expert Comment

    by:nan1217
    The properties didn't work for me.

    Here's an example of someone else using these properties in a PAQ.  http://www.experts-exchange.com/Web/Web_Languages/CSS/Q_21118256.html
    0
     

    Expert Comment

    by:Gary_Eisert
    What I do is pick a tag where you want the page to break. In this example I used the  H3 tag

    In the header add this line

    <STYLE>H3 { PAGE-BREAK-BEFORE: always }</STYLE>

    Wherever the <H3> is in the body of your page it will produce a page break.

    In order to test it, use IE 5+ and try the Print Preview. You should be able to see if it works on screen.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    The viewer will learn how to count occurrences of each item in an array.

    856 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now