Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing only a textarea

I would like to print only the contents of a textarea element from a website page. In particular, I would like to ensure that nothing gets clipped by the boundary of the textarea as the contents will be quite large.

What is the best strategy for tackling this?

like image 357
torial Avatar asked Nov 07 '08 16:11

torial


3 Answers

Make a print stylesheet where all of the elements except the textarea are set in CSS to display: none;, and for the textarea, overflow: visible.

Link it to the page with the link tag in the header set to media="print".

You're done.

like image 53
John Dunagan Avatar answered Nov 09 '22 21:11

John Dunagan


Make a different CSS with media set to print

<link rel="stylesheet" type="text/css" href="print.css" media="print" />

http://webdesign.about.com/cs/css/a/aa042103a.htm

like image 31
Lou Franco Avatar answered Nov 09 '22 19:11

Lou Franco


If the user clicks "Print," you could open a new window with just the contents of the textarea on a blank page and initiate printing from there, then close that window.

Update: I think the CSS solutions being suggested are probably better strategies, but if anybody likes this suggestion, they can still upvote it.

like image 2
Nathan Long Avatar answered Nov 09 '22 21:11

Nathan Long