Click here to Skip to main content
15,116,654 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
How to print multiple pages at a time in HTML/JAVASCRIPT?

I have series of web pages and print button is placed at last page.
all the pages captures the user data, when user reaches last page we supposed to print all pages.

Note : print button is placed at the last page.

How can i achieve the same.

Kindly help me out !!!

Regards
Roopa
Posted
Updated 15-Jan-10 2:27am
v2

1 solution

Hey Roopa,

Dont know exactly your case, so ill just post quick thoughts:

The easiest would be if you catch the output of all the pages with your backend (re: asp, php, whatever it is), and store it in the session. At the last page, the print button would then load a separate page (popup, _blank), where you just output all the cached html from the sesssion (only the contents ofcourse).

Another way would be if you are loading your pages with ajax (so, no real page reload), you can store each step (page) with a javascript hook (body onload) in a global javascript variable (array). At the end the print button loads in the body (or in a new windows) all the content one after the other from the javascript array.

Note that separating it to real pages is not really possible in a good way with html... it would be a browser decision when to put a page break. I solved a similar scenario by exporting the html to pdf, then you can handle page breaks much easier, but i guess its going too far :).

Hope any ofthe thoughts above help.

Best,

Boyan
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900