tags:

views:

31

answers:

1

’m working on a project that allows users to design forms in a web editor. Some of that content is growing/variable in nature (we run a process against it and add/replace various HTML tags).

The end requirement is that this form be printable and look super fantastic.

In order to make this printable, I need to insert page breaks appropriately to ensure the content breaks where we want it to and not in some arbitrary location. For the most part this works, but under certan scenerios, it’s not happening.

Below is a simplified piece of HTML that is causing problems. The real content is much more complex, but this demonstrates the problem. It seems that the first is being ignored by IE8.

If you open this up, and select print-preview, you will see “This is page 1” and “This is page 2” both on page 1.

Any ideas why this isn’t working? I've been fiddling with it all day trying to figure out whats wrong.

<body>
    <div style="width: 8.5in; height: 100%; position: relative; ">         
        <div style="left: 0.5in; width: 7.5in; top: 2.8in; position: absolute; overflow: visible; " id="editor4">            
            <div style="position: relative; overflow: hidden; " id="MsgBlock9">                    
                This is page 1.
            </div>                                                               
            <div style="page-break-after:always"></div>                
            <div style="position: relative; overflow: hidden; " id="MsgBlock15">                    
                This is page 2                               
            </div>                
        </div>
    </div>
    <div style="page-break-after:always"></div>                       
    <div style="width: 8.5in; height: 100%; position: relative; overflow: hidden;" >                
        <div style="left: 0.7in; top: 0.25in; width: 7.5in; height: 100%; position: absolute; overflow: hidden; " id="editor9">
            This is page 3
        </div>
    </div>
</body>
A: 

Just a shot in the dark but try giving the div some content, e.g. by adding a &nbsp;:

<div style="page-break-after:always">&nbsp;</div>      
Pekka
Tried that. No go.
Bremer
@Bremer On second look, I *think* the problem is that you are doing the page break in an element that has `height: 100%`. Is there any way to get around that?
Pekka
I just tried removing that, no change. I have control over the <div> tags, but not over the content that will go in them. So if I need to update teh styles or something, I can do that. I've been tweaking these all day with no luck.
Bremer
@Bremer I see. Have you considered generating PDF files instead? It's a learning curve and some work to set up, but the results would be almost 100% reliable across browsers and platforms
Pekka
Actualy, we ARE generating PDF's. The user builds their template using an HTML editor online. We apply their data to that template, and then convert the HTML into a PDF. The PDF is then printed, and mailed. The problem is that without page-breaks, the PDF will not look as intended. I didn't choose this path, and I'm stuck making it happen. I have voiced my opinion that this is probably a bad way to do this, and been told to shut up and code. :P
Bremer