Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print multiple generated html pages?

Status
Not open for further replies.

RandyBlackburn

Programmer
Oct 1, 2002
153
US
I am generating a complex html page multiple times based on query resuts (like a report). I would like to be able to print the pages by a single action (like clicking a button, or... automatically). I would prefer to generate the pages in the background.

Any help will be most appreciated.

Randy
 
You can't automatically print pages, however, once you open and load a page you can use a javascript method (window.print) o pop up the print dialog page for the user.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
OK for the trigger. But my main problem is how to group the pages and print them all at the same time. They are all generated from the same aspx+code behind, so they have the same url.

Can I somehow concatenate the pages into a single file, or pass the pages somehow among successive calls to the page?

And is there a way to produce them somehow in the background?

Randy

 
Ideally, you would just create a link for each page and get the user to open each one individually and then print them.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Boy, we're up late, and I appreciate your help!

But I don't consider clicking on each page (and there could be quite a few) as ideal. Ideally, for me, the user won't even see the pages being produced, and will click to print only once.

I assume you don't have an approach to do that?

I guess I may have to do as you suggest, but it seems that a file of html could be built, appending each page as produced, with page breaks included.. then the result could be printed. It's just that I'm not sure how to do it.

Thanks again,
Randy
 
Boy, we're up late, and I appreciate your help!
9am isn't late for me!

But I don't consider clicking on each page (and there could be quite a few) as ideal
When I say ideal, I mean from a web accessibility point of view i.e. it will be accessible to any user regardless if they have javascript or not and also conforms to w3 recommendations i.e. no pop up windows.

it seems that a file of html could be built, appending each page as produced, with page breaks included.. then the result could be printed
Yes, that is possible. You can create a httpWebRequest to each page, read the results via the httpWebResponse and then append them all into one file and stream it to the client.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
9am isn't late for me!
Where are you located?

When I say ideal, I mean from a web accessibility point of view i.e. it will be accessible to any user regardless if they have javascript or not and also conforms to w3 recommendations i.e. no pop up windows.
Fortunately this system is used on an intranet, where they all have the same configurations

Yes, that is possible. You can create a httpWebRequest to each page, read the results via the httpWebResponse and then append them all into one file and stream it to the client.
That's the ticket... but that's what I don't know how to do. Can you be more specific, or provide an example?

Randy





 
I'm based in the UK so there will be an 8 hour time difference between us, I think.

The httpWebRequest is fairly easy to use and you can find the details and an example from:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Have you had any luck with httpWebRequest Randy?

Thanks,
Jo
 
I have much success with HttpWebRequest, jo112 - what do you ned help with?
 
Basically, I have the same problem as Randy, I am generating multiple html pages and I would like to print them all on one click.
 
Jo112 - No when I didn't hear anything, I just decided to present/print each page individually. I haven't had a chance to check out Ca8msm's msdn reference. I'd love to see an example from tperri.

Randy
 
tperri,
How does it work if multiple pages are populated with data on the fly?

Randy
 
read the streams into a string.. you may need to remove some tags so yo udont have multiple <html><head><body> couplets, but thats simple enough.

then output that string onto your page for printing. use CSS to stylize your printing if necessary.
 
sorry-

you cant re-generate those pages on the fly through a scrape? perhaps you need to enable those pages to gwenerate from querystring values so its possible to do the screen scraping?
 
The query string could work... can I pass a session variable, as that's what I'm doing now?

do the pages show as they are being populated?

I'd like to click on the print button, and then have multiple dynamic pages print (hopefully in the background).

Thanks,
Randy
 
you cant pass a session variable in a screen scrape as it only accepts a url... put some error catching code if the session variable isnt there then look for the query string.. though technically the session variable should be set already at that point (i'm assuming) and is useable.

maybe you can pass q uerystring parameter that indicates you're printing so yuo can skip the code you have for displaying the data and just go right to a routine that performs the print processsing.

and in the background i dont see why you couldnt do that the same way you are doing it now for one page after you get the data from a stream into something you can parse and print.

just typing as i'm thinking here. sorry if i'm all over the place.
 
maybe you can pass q uerystring parameter that indicates you're printing so yuo can skip the code you have for displaying the data and just go right to a routine that performs the print processsing.

I guess I don't know how to process a page without showing it????

and in the background i dont see why you couldnt do that the same way you are doing it now for one page after you get the data from a stream into something you can parse and print.
I'm not sure I understand...

Randy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top