Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    trying to prevent table from printing part on two pages

    Hi,

    I am outputting a page which has four tables on it. looks fine in the browser and I am now doing the print css.

    How can I force a table to print on one page rather than starting on one and finishing on the next?


    I have tried the
    Code:
    page-break_inside:avoid
    but it seems not to work.

    Code:
    #bookings_details_panel table {
      width : 100%;
      margin-top:10px;
      border:0;
      page-break-inside:avoid;
    }
    bazz
    Last edited by bazz; 10-28-2009 at 05:56 PM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Looks like it's only supported in Opera...
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thanks Rowsdower; well spotted. I had seen that the prooerty is supported by all major browsers but hadn't seen that 'avoid' was only supported by Opera.

    OK, so is there any way to be sure that if a tbale were to be straddling two pages, that it is to be printed on just one? without js?

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Well, the "avoid" is not the Opera-only part (as far as I know) - it's the entire page-break-inside style. All major browsers support page-break-before and page-break-after (and support the avoid property for it, too). It's a shame, really, as this would be a very convenient feature.

    Anyway, I've never seen any HTML/CSS solution for this exact problem so you probably would have to resort to scripting (perhaps even a server-side addition of a no_break class or something when the table has more than "x" <tr>s in it) or else purposely breaking the page before each and every table using page-break-before. Obviously you can get creative with work-arounds, but for any sort of native and natural support for what you're after I think you're sunk.

    Edit: I take back the part about all browsers supporting "avoid" as it appears as though FF, Chrome, and Safari DO NOT support it. Still, nobody but Opera supports page-break-inside. I have read that page-break-inside:avoid; is part of the default behavior for CSS2 though but I'm not sure if that's accurate at all.
    Last edited by Rowsdower!; 10-28-2009 at 06:35 PM.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Thanks.

    I have ensured that my first two tables are of a standardised height. They have a maximum number of rows to output and if in some cases, fewer will be outputted, I have made the script output empty rows, with a simliar height as when populated so that the table will be of the same height regardless of its content.

    So, provided they page to be printed on is A4; it works fine for FF and IE6. Got to check IE7 and 8 before I can consider it reasonably proficient.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •