...

Printing multiple pages -- does it require server side?

smanning
11-05-2002, 04:01 PM
Hello,

I'm trying to come up with a print button that allows the user to print a series of pages (a "print all" button).

I can easily write a Javascript that prints the window the user is currently in, but am not sure how to modify it to print other pages the user is not in. Can Javascript do something like this, or is this something only server side scripting can do?



Thanks for your insight,

Steve

Roy Sinclair
11-05-2002, 06:15 PM
Javascript can do that by loading each page into an IFRAME and then printing it but that would cause the user to get prompted once for each web page to be printed. You could also run a series of IMFRAMES to load all the pages into a single combo page and print it and only end up prompting the user once.

smanning
11-12-2002, 09:29 PM
Ok, that works for recent browser versions. Thanks! But unfortunately I have to make it work for Netscape 4 as well, and I understand Netscape 4 doesn't recognize IFRAME.

Anybody have any thoughts on this?

kwhubby
11-16-2002, 07:47 AM
could you have just plain frames that were all printed at the same time? but this might still require prompts for each time.

Another Idea might be to have an array that equals the sources for each page. And depending on wich combo pages to print, the sources could be added and made into one thing to do a write() with. and then printed such as:
function combp() {
var x = new Array(4)
x[0] = "hi how are you"
x[1] = "whats up"
x[2] = "be happy (:"
var sr = "<html><script>document.print()</script><body>"
for (var i = 0; i < x.length; i++) {
if (elements[i].checked) {
sr = sr + x[i]
}
}
sr = sr + "</body></html>
document.write(sr)
}
<body>
1<input type="checkbox">
2<input type="checkbox">
3<input type="checkbox">
4<input type="checkbox">
<input type="button" value="print selected" onClick="combp()">

This script might have errors in it ( not sure about elements[i].checked) but I just made it as an example, the sr value would be what ever you needed the script tag or meta tag to be, for the printing, and the values of x would be the source inside the body tag of each page

kwhubby
11-16-2002, 08:00 AM
<html>
This one actualy works (at least in IE, not sure if getElementById works in netcape):

<script>
function combp() {
var x = new Array(3)
x[0] = "hi how are you <a href='http://google.com'>google</a> "
x[1] = "whats up "
x[2] = "be happy and google (: <img src ='http://www.google.com/images/logo.gif'>"
var asdf = "<html><body onload='javascript: window.print();'>"
for (var i = 0; i < x.length; i++) {
if (document.getElementById("m" + i).checked) {
asdf = asdf + x[i]
}
}
asdf = asdf + "</body></html>"
document.write(asdf)
document.close()
}
</script>
<body>
1<input type="checkbox" name ="m0">
2<input type="checkbox" name ="m1">
3<input type="checkbox" name ="m2">
<input type="button" value="print selected" onClick="combp()">
</html>

edit:
hmm. thats really wierd, the onload='java script actualy is onload='javascript
but the forum is making it have a space??!!!

Roy Sinclair
11-18-2002, 08:16 PM
Originally posted by smanning
Ok, that works for recent browser versions. Thanks! But unfortunately I have to make it work for Netscape 4 as well, and I understand Netscape 4 doesn't recognize IFRAME.

Anybody have any thoughts on this?

Netscape 4 has a near enough equivalent to IFRAME called ILAYER that you should be able to use for the Luddites in your organization.

chrisjacks
03-15-2006, 05:06 AM
I'm trying to come up with a print button that allows the user to print a series of pages (a "print all" button).

I'm trying to do this too but so far have had no luck...

<html>
This one actualy works (at least in IE, not sure if getElementById works in netcape):

<script>
function combp() {
var x = new Array(3)
x[0] = "hi how are you <a href='http://google.com'>google</a> "
x[1] = "whats up "
x[2] = "be happy and google (: <img src ='http://www.google.com/images/logo.gif'>"
var asdf = "<html><body onload='javascript: window.print();'>"
for (var i = 0; i < x.length; i++) {
if (document.getElementById("m" + i).checked) {
asdf = asdf + x[i]
}
}
asdf = asdf + "</body></html>"
document.write(asdf)
document.close()
}
</script>
<body>
1<input type="checkbox" name ="m0">
2<input type="checkbox" name ="m1">
3<input type="checkbox" name ="m2">
<input type="button" value="print selected" onClick="combp()">
</html>


This is the closest thing I've seen to what I'm actually after. Nice work! The main problem with this code is that you have to have the X array hardwired by the looks of it.

Is it possible to replace the content of each array record with code from different HTML pages like in my dodgy example below?


x[0] = "===I want the content from mypage1.htm to go in here==="
x[1] = "===I want the content from mypage2.htm to go in here==="
x[2] = "===I want the content from mypage3.htm to go in here==="

Any help is very much appreciated! Thanks!
Chris

salma66
09-08-2011, 11:06 AM
5 years have passed and I still trying to solve this problem!!! :(

morongo47
09-24-2011, 05:46 AM
5 years have passed and I still trying to solve this problem!!!

You're kidding, right?

If not, root through some of this stuff and see if it gives you any ideas on something you can cobble together.

http://graciesdad.wordpress.com/2007/04/19/all-in-one-printing-from-multiple-iframes/
http://www.codingforums.com/showthread.php?t=151336
http://www.codeproject.com/Answers/52548/How-to-print-multiple-pages-at-a-time-in-HTML-JAVA.aspx#answer1
http://dryicons.com/blog/2008/04/26/multiple-page-printing-from-a-html-adobe-air-application/
http://tycoontalk.freelancer.com/javascript-forum/145938-how-print-multiple-pages-using-javascript.html
http://windows.podnova.com/software/178768.htm
http://justtalkaboutweb.com/2008/05/09/javascript-print-bypass-printer-dialog-in-ie-and-firefox/
http://www.menace.co.nz/egovt/13.1.html
http://www.techtricky.com/print-part-of-page-javascript/
http://www.codestore.net/store.nsf/unid/DOMM-4WMEU6

You know, one way would be to populate just one iframe (or layered div) with a concatenated set of pages (which php could handle) and then print that out.

You could have php insert page breaks as desired before sending the pages to the iframe - one click would send it to the printer - keep it simple, one ajax call with the parameters set to the desired pages would do the trick. I'd recommend one shared css for the bunch, the browser might choke on any more than that (and they have, if you read through the experiences cited in some of the links above).

.
.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum