HOW TO PRINT IN JAVA?

Hi everyone,
i made a page in jsp in which there is a combobox which contain different users like admin,faiyaz,ali etc....
question is that when i select 'admin' from combobox and click on 'generate report' button.new page opens which show report of 'admin' activities.there is a one PRINT link on page.when click on print report will be printed...
how can i print particular report page which is opened?
help me regarding this problem...
thnxs in advance
with regards

create a CSS file called print.css for example then add it to your JSPs like that
<html>
<head>
<link rel="stylesheet" media="print" href="<%=request.getContextPath()%>/print.css" type="text/css" />
</head>
<html>In this CSS file, add code that hides links and other things you want to hide(or show) when printing
Use javascript window print function like this:
<a href="javascript:window.print()">Print</a>
NB: This is a web question and has nothing with Java

Similar Messages

  • How to print in java(page or whole frame with photos)

    Hell sir,
    My self kiran patel.I am going to devlop a visitor information system project for Ongc(stand-alon application)
    I want to know about below topics.
    (1) How to print simple page using printer in java.i dont know any code.
    (2) Printing page should contain the whole page which include information and photo of visitor.
    (3) how to catch the photo in data base or my frame of visitor info. which we have taken throw web-came.
    (4) can we store any image in database?
    Please help me as possible as soon.......
    kiran patel(MSc it)

    Background study -
    http://java.sun.com/docs/books/tutorial/2d/printing/index.html
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • I need to learn how to print in Java 1.4 (Printing  tutorial needed)

    Hi
    I need to find a really good Printing tutorial.
    Can anyone tell tell of a good tutorial.
    Please don't ask my to do a Google search as I have already :)
    Thanks
    Craig

    All you ever wanted to know about Oracle Reports:
    http://www.oracle.com/technetwork/middleware/reports/documentation/index.html

  • How to print a text in java?

    How to print a text in java?

    of corse, i have JTextField in my frame that i want to extract the text and print it on a paper with a printer.

  • How do i use java printing api 1.4

    How can i print documents using jdk1.4 api.
    I have used the following program for printing.
    import java.io.*;
    import java.awt.*;
    import java.awt.print.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    public class Print2DtoStream implements Printable{
    public Print2DtoStream() {
    /* Use the pre-defined flavor for a Printable from an InputStream */
    DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    /* Specify the type of the output stream */
    String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
    /* Locate factory which can export a GIF image stream as Postscript */
    StreamPrintServiceFactory[] factories =
    StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType);
    if (factories.length == 0) {
    System.err.println("No suitable factories");
    System.exit(0);
    try {
    /* Create a file for the exported postscript */
    FileOutputStream fos = new FileOutputStream("out.ps");
    /* Create a Stream printer for Postscript */
    StreamPrintService sps = factories[0].getPrintService(fos);
    /* Create and call a Print Job */
    DocPrintJob pj = sps.createPrintJob();
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    Doc doc = new SimpleDoc(this, flavor, null);
    pj.print(doc, aset);
    fos.close();
    } catch (PrintException pe) {
    System.err.println(pe);
    } catch (IOException ie) {
    System.err.println(ie);
    public int print(Graphics g,PageFormat pf,int pageIndex) {
    if (pageIndex == 0) {
    Graphics2D g2d= (Graphics2D)g;
    g2d.translate(pf.getImageableX(), pf.getImageableY());
    g2d.setColor(Color.black);
    g2d.drawString("example string", 250, 250);
    g2d.fillRect(0, 0, 200, 200);
    return Printable.PAGE_EXISTS;
    } else {
    return Printable.NO_SUCH_PAGE;
    public static void main(String args[]) {
    Print2DtoStream sp = new Print2DtoStream();
    However when i run this program,it prints "example string" as used in g2d.drawString("example string",250,250) method above.
    What if i want to print content from any file.
    So anybody konwing this plz reply

    This is covered pretty well in the Java Print Service API Guide.
    You could start here http://java.sun.com/j2se/1.4.1/docs/guide/jps/spec/printing.fm1.html
    Basically, you have two choices - either you're going to throw a document at the print service, or you're going to print using Graphics2D commands. You also have the choice between printing to a printer, or to a stream. Mix and match for four combinations.
    Whether you can just take a raw document and send it to a printer via the document printing stuff depends on what print services you have installed. For the standard J2SE, it's pretty limited.
    If you're doing it via the Graphics2D approach, however, you can print anything you can draw. That's nice - it means you can use the same code to display stuff on the screen and print it.

  • How to print/list all the groups/users present in Weblogic using Java code

    Hi,
    Weblogic version : 11.1.1.5
    How to print/list all the groups/users present in Weblogic using Java code
    I want to make a remote connection to Weblogic server and print all the users/groups present in it.
    I have gone through the below mentioned site, but I cannot use the same approach since most of the API' are deprecated for example "weblogic.management.MBeanHome;"
    http://weblogic-wonders.com/weblogic/2010/11/10/list-users-and-groups-in-weblogic-using-jmx/
    Thanks in advance,
    Edited by: 984107 on 05-Feb-2013 05:26
    Edited by: 984107 on 05-Feb-2013 22:59

    see this http://www.techpaste.com/2012/06/managing-user-groups-wlst-scripts-weblogic/
    Hope this helps.

  • How to print line numbers in NWDS for Java?

    Hi everyone,
    does someone know how to print out program code with line numbers from the Netweaver Developer Studio for Java? This is inevitable for code reviews.
    In Eclipse 3.4 this issue is solved. Is there possibly such a patch for NWDS as well?
    Thanks,
    Maria

    Hi Pascal,
    thanks for the quick reply. The setting you mention displays line numbers on the screen alright, but printing out does not work.
    We use: SAP NetWeaver Developer Studio for SAP NetWeaver 7.1 SP06 PAT0000, Build id: 200807051938.
    I guess it just does not work, because it was fixed only for Eclipse 3.4, and the above NWDS version bases on Eclipse 3.3.
    What do you recommend for code inspections - copy/paste into PSPad or do you know a more comfortable practice?
    Greetings
    Maria

  • How to print  Excel file in java?

    Hi, all
    I had written a program to generate a Report with Excel in java using the jexcelapi_2_5_7 . But I don't know how to print it in java program. It seems that java print Service don�t support Excel flavor. How should I do? It will be a great appreciate for me if anyone could help me.
    Regards
    David

    Hi ,
    i m asking if you got a solution for your problem ;
    i need solution to the same problem
    thx in advance

  • How to print "Text" in JAVA(TM)....

    Does anyone know how to print "text" using Java?
    - Here's an example output...
    NOTE: # == 'empty spaces'
    --------------------------- <- Paper
    |###################|
    |####Welcome#########|
    |###################|
    |########to##########|
    |###########JAVA(TM)##|
    |###################|
    |#######Programming####|
    |###################|
    Please post a complete << SAMPLE CODE >> for printing the "text" (Welcome to JAVA(TM) Programming. Including the indentions. So it will not be like this...
    -------------------- <- Paper
    |Welcome |
    |to |
    |JAVA(TM) |
    |Programming |
    | |
    | |
    | |
    | |
    Thanks.

    Please read How To Ask Questions The Smart Way

  • HOW TO PRINT  THE EXCEL CELL COMMENT IN JAVA SWING FRAME ?

    How to print the excel cell comment in java swing frame
    user can print the data of cell with comment in bracket in java swing frame.
    please make one java code to read an excel spreed sheet and print the output in Java swing frame as follows
    EMP NO - 1, 2, 3
    EMP NAME - aname (amitesh:very good), bname (amitesh: average), cname (amitesh: very bad)
    EMP AGE - 11, 22, 33
    EMP DESG - ad, bd, cd
    Note: the bracket portion is the excel comments put in that cell

    hello everyone i'm new to this forum..how are you all...
    Jack Brosnan
    [mobile phone|http://www.mobilephonesforsale.net.au/apple-iphone-f-2.html]

  • Funtion is returning jstring, how to print it in java code

    Plz let me know how to print a jstirng which is returning by a native function in java.
    When i use System.out.print(view());
    it gives me error.
    what i shoulr do with jsting so that i can use/print it in java.

    dscdscWhat do you mean by that?

  • How to print the image data stored in object of 'java.io.File' Class in jsp

    I have created a file object for the image file in the system temporary directory.Now I want to display it in my page. please tell,How to print the image data stored in object(in my program it is imgr) of 'java.io.File' Class in jsp

    Create a servlet which gets an InputStream of the file and writes it to the OutputStream of the response and call this servlet in `src` attribute. That's basically all.
    Here's an example which covers the most of the minimum needs: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • How to print PDF files using java print API

    Hi,
    I was goign throw lot of discusion and reading lot of forums related to print pdf files using java api. but nothing seems to be working for me. Can any one tell me how to print pdf files using java api.
    Thanks in advance

    Mike,
    Can't seem to get hold of the example described in your reply below. If you could let us have the URL to get then it would be great.
    My GUI application creates a pdf document which I need to print. I want to achieve this using the standard Java class PrinterJob (no 3rd party APIs I'm afraid, commercial restraints etc ..). I had a stab at it using the following code. When executed I get the pretty printer dialog then when I click ok to print, nothing happens!
    boolean showPrintDialog=true;
    PrinterJob printJob = PrinterJob.getPrinterJob ();
    printJob.setJobName ("Contract.pdf");
    try {
    if (showPrintDialog) {
    if (printJob.printDialog()) {
    printJob.print();
    else
    printJob.print ();
    } catch (Exception PrintException) {
                   PrintException.printStackTrace();
    Thank you and a happy new year.
    Cheers,
    Chris

  • Printing in java? Does anyone know how?

    Um ......cant seem to find any tuorials on printing in java.
    Does anyone know how. I have a bit of text in a JTextArea that i just wanna print directly to the printer. No hassles.

    If you're trying to print in JDK 1.2 or 1.3 there is an online tutorial here:
    http://java.sun.com/products/java-media/2D/forDevelopers/sdk12print.html
    Things have drastically changed for Java 2, JDK 1.4, and the new printing API/User guide can be found here:
    http://java.sun.com/j2se/1.4/docs/guide/jps/
    I have been having trouble with the locating printservices with the jdk 1.4, but it is still in BETA, so that could be the problem.

  • HT4623 How can I install Java so I can print coupons. My IOS is updated to 6.1

    How can I install Java to print coupons. I have already updated my IOS to 6.1.

    As far as I know, you can't. Does your coupon place have an app? That's the best way to get things like that working on an iPad.

Maybe you are looking for