wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Print selected content from Div area using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Print selected content from Div area using javascript" Watch "Print selected content from Div area using javascript" New topic
Author

Print selected content from Div area using javascript

Robert Jack
Ranch Hand

Joined: Apr 13, 2010
Posts: 46
Hi,

I have some content in div area. I want to take printout the selected content from div.

In my javascript, If i select 3 lines from div content, after print out, i get the 3 line content as single line. not 3 line.



Help me,
Thanks in advance
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Try this

http://stackoverflow.com/questions/4176923/html-of-selected-text

I hope it help your problem.


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Don't forget that in HTML, line-ending characters in text are treated like spaces. And two spaces together are treated like one space. This is how HTML normalizes text. So that's why your text looks like one line, because that's how HTML works.

If you want to preserve the line endings, you have two options. One is to wrap the text in a <pre> element, which causes the usual normalization rules to not be applied. You may or may not like the way that looks, though. The other option is to replace the line-ending characters by
elements, which as you know cause the text to break to the next line. Which is what you want. Make sure that those
elements are treated as HTML markup and not as text if you do that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Print selected content from Div area using javascript
 
Similar Threads
Onload script does not work in subview page
Is this a correct approach to use subviews for partial page refresh?
rich:hotKey worked when using jQuery?
How to stop page refresh when hit enter button from rich:inputNumberSpinner field?
How to print a image file into the printer