Jump to content

printing multiple pages with css


RIRedinPA

Recommended Posts

I folks. I am trying to send a document to the printer via javascript and use css to insert page breaks but I am having no luck with it. I keep getting just one page printed out with no breaks, it just bleeds off the bottom of the page where the break should be.

 

Here's my CSS set up:

 

                       body {
			margin: 0;
		}
           
                       #printpreview {
			position: relative; 
			margin: 0 auto;
			top: 150px;
			height: 540px;
			width: 420px;
			background-color: #eee;
			text-align: center; 

		}

		#printpreview img { 
			position: relative; 
			top: 10px;
		}

		#printpreview a {
			font-size: .8em; 
			font-weight: 500; 
		}

                       @media print {
				.pagebreak {
				page-break-before: always;
			}
		} 

 

Here's the javascript code:

 


function printokay(pages) {

		var printcode = "";
		var pagearray = pages.split(",");
		for (var x=0; x<pagearray.length; x++) {
			var imgnum = leftTrim(pagearray[x]);
			if (x+1 < pagearray.length) { 
				printcode += "<div id=\"page_" + imgnum + "\" style=\"width: 600px; height: 800px; border: 1px solid black;\" class=\"pagebreak\"><img src=\"http://macdev2.xxx.com/printtest/images/ot/090109/adv_ot_pg" + imgnum + ".jpg\" height=\"100%\"></div><a name=\"break2\" class=\"pagebreak\"><p>";
			} else { 
				printcode += "<div id=\"page_" + imgnum + "\" style=\"width: 600px; height: 800px; border: 1px solid black;\" class=\"pagebreak\"><img src=\"http://macdev2.xxx.com/printtest/images/ot/090109/adv_ot_pg" + imgnum + ".jpg\" height=\"100%\"></div><p>";
			}
		}

		document.getElementById('printwin').style.left = "0px";
		document.getElementById('printwin').innerHTML = printcode;


		window.print();
	}

 

Any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.