File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Printing textual data from browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Printing textual data from browser" Watch "Printing textual data from browser" New topic

Printing textual data from browser

Jeevan Sunkersett
Ranch Hand

Joined: Jul 03, 2007
Posts: 78

Ours is a web based (Struts, Spring, Hibernate) application.
In a particular use case, print-receipt; we pull up data from database and display it a new window ... followed by a javascriptLwindow.print()

To print the content.

But this prints the browser window - in graphic mode.

The target printer, attached to the browser machine is a Dot matrix printer; and consumes a lot off time to print a single window (because of the graphic nature)

Can the printing be done in text mode ?

thank you.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63540

You can either:
  • Use CSS to control what gets printed.
  • Instead of window.print(), have the link serve a PDF of just the data you want to print.

  • [Asking smart questions] [About Bear] [Books by Bear]
    Pete Nelson
    Ranch Hand

    Joined: Aug 30, 2010
    Posts: 147

    I don't know that JSP will offer you much in terms of client-side printing. However ...

    Depending on the Browser you are using, you may be able to take advantage of CSS to change the way the page prints.

    Here's a good starting point for CSS for print media -

    In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
    Jeevan Sunkersett
    Ranch Hand

    Joined: Jul 03, 2007
    Posts: 78

    for the benefit of everyone, this solution worked for me;

    subject: Printing textual data from browser
    It's not a secret anymore!