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
https://forums.phpfreaks.com/topic/175254-printing-multiple-pages-with-css/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.