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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you print and save specific DIV's in a web page?

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034

i have a receipt page and i need to print only a certain section of it...i think i can contain the print part in DIV's, but using the following code i don't know how to initiate the actual 'print' action...i actually just found this, don't really know how it works...

Code:
@media print {
 #container {
  height: auto;
  overflow: visible;
 }
}

now as far as saving, how do let them choose where they want the save/download to go to?

any ideas?

- g
 
CSS allows loading different stylesheets for different media (click for more info). In that way you can define any part of your website to be printed or no. With JavaScript you can also switch between different stylesheet so you might want to make a script that switches the stylesheet and then prints. However, this wouldn't be necessary in most cases, because you can have many stylesheets loaded in a page and they will be automagically available for their respective medium.
 
See thread770-1021503 for a little more background on this. Printing is one thing - saving / downloading is quite another. If you have a receipt page, set up 'print' css to just display the relevant parts as in the above thread, and have the users print it.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top