Printing in Java 5

Dear All,
I have a HTML file contains two tables, one is the summary table and the other one is the detail one. The HTML is displayed in the JEditorPane. Could anyone suggest me with the example code on how to do if I want to print in directly (using DocumentRenderer?) from Java with requirements:
1. I want to have header and footer.
2. The summary table is quite long hence it is printed more than one page. I want it to be fitted in one page. It does not matter for the detail table.
Thank you very much for your help.
Kind regards,
Daniel

Hmmm. This is about the time my printer stopped printing too. I've now had two printers in my house and had trouble with both of them. What a pain we should not have to delete updates for our stuff to work together.
Renee

Similar Messages

  • Configure client printer in java.awt.print

    I have number of records in database.
    If User clicks on PRINT button (ON A JSP PAGE)each record should be printed(ON CLIENT PRINTER) on a separate sheet.
    I can only able to access printer connected to server not to client.
    I am using javax.print and java.awt.print packages

    I am not sure this..
    Instead of if pls give while and check:
    try{
    while(rsValue.next()) {
    g.setFont(fntHeading);
    g.setColor(Color.red);
    g.drawString("Main Report",200,100);

  • XML Printing from Java

    I have an urgent request from my company's client to implement a feature of printing in our application.
    Actually the application is basically an XML Builder which generates XML code at the backend, something like Dreamweaver.
    I have no clue about printing in Java, and have not much time to research on this topic. If anybody have a program to send an XML file to print (Color printing if possible), please post here or email me at [email protected]
    Any help in this regard is highly appreciated (Dukes Dollars also available).
    Thanks
    Raheel

    I realize you're under time pressure, but this link may be of assistance: Printing in Java, Part 1: Acquaint yourself with the Java printing model

  • PL/SQL log messages are not printing from Java concurrent program

    Hi,
    I have a strange issue while submitting the Java concurrent program through PL/SQL.
    I have a PL/SQL concurrent program which will invoke the Java concurrent program inside the package by use of "FND_GLOBAL.SUBMIT_REQUEST". It worked and submitted successfully. From that Java concurrent program we are calling some other PL/SQL packages and printing some log messages over there. But problem here is the request is only printing the Java log messages in view log but not the PL/SQL log messages.  But if I submit the Java concurrent program directly from SRS form at that it is printing both Java and PL/SQL log messages.
    I am just wondering how the log messages has not printed. Please provide your inputs to solve this problem.
    Thanks
    Suriya

    I'm adding log messages in the package body , but these messages are not printing after completion of concurrent prog.
    Any suggestions.
    FND_FILE.PUT_LINE(FND_FILE.LOG,'Data Test :');Do you have COMMIT in your code?
    https://forums.oracle.com/forums/search.jspa?threadID=&q=%27FND_FILE.PUT_LINE%27+AND+commit&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Help needed in printing in java

    hello everyone, i m in grave need of a solution of printing a java page. I have a page designed in Java swings which contains mainly labels and textareas. And i need to print this page. The problem is that I have no clue how to go ahead. Cud neone arnd pls help me on this matter asap as this is very urgent. I shall be highly obliged to all the takers on this issue. Please email me at [email protected]
    Thanks and kind regards,
    Rahul.

    http://java.sun.com/docs/books/tutorial/2d/printing/index.html

  • Problem in printing a java swing form

    Hi,
    Could anyone help me on how to set the page margings while I print a java swing form since it is taking a lot of space as margins in the top right top and bottom how do i do that. or is it that java can only print in the printable area or is there any way i can increase the scope of the printable area

    I used PrintRequestAttributeSet and set the margins to 0.5 on all four sides by creating an instance of MediaPrintableArea. By default, the margins on all sides comes up as 1.0 inch. Default paper size is LETTER (8.5 x 11).
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new MediaPrintableArea(0.5f,0.5f,7.5f,10.0f,MediaPrintableArea.INCH);
    PrinterJob printJob = PrinterJob.getPrinterJob();
    printJob.setPrintable(component);
    if(printJob.printDialog(aset))
    printJob.print(aset);
    hope it helps.

  • Text Printing in Java

    How can i print characters with different styles in a dotmatrix printer using print api

    Well, getting the text from your JTextField should be rather easy: myJTextField.getText().
    To print it, you'll have to create an Graphics object and draw the text using the drawString method on a Graphics objects: myGraphics.drawString(myText, x, y). You will need to set the right font on the graphics before that (using the setFont() method).
    You can then use this Graphics object to print.
    See the java tutorial on printing for more info about printing: http://java.sun.com/docs/books/tutorial/2d/printing/overview.html

  • Printing in java - text positioning

    Hi there, I need some pointers in the right direction please.
    I need to print a page out to fill in a pre-printed sheet. The data to go onto the sheet is purely numbers, but the pre-printed sheet is not in a table format (the boxes where the data goes are in seemingly random positions.)
    I am currently completing the task by laying out a panel in the way I want it and using the printComponent method, but this obviously isnt the best way to do it as all I need to print out is text.
    How is the best way to go about this? Is it possible to define the position of each line of text?
    Cheers. :)

    Well, getting the text from your JTextField should be rather easy: myJTextField.getText().
    To print it, you'll have to create an Graphics object and draw the text using the drawString method on a Graphics objects: myGraphics.drawString(myText, x, y). You will need to set the right font on the graphics before that (using the setFont() method).
    You can then use this Graphics object to print.
    See the java tutorial on printing for more info about printing: http://java.sun.com/docs/books/tutorial/2d/printing/overview.html

  • 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

  • Printing From Java "The most F%&()�G stupid thing in the world"

    I have Spent the whole day trying to print a JPanel out of My application. I have gotten the panel to print but the print is not consistant. If the User Changes the Size of the Fame the Panel size Changes and Dimensions of the Plot Changes (aspect ratio). This happens because A print call makes a an image and then scales the image!!! Would it not make way more sence to scale the Jpanel to fit into the specified page size and then make an image to print! I anyone nows of way to do this Please!!!!!!!! let me know.

    I think the above post is an understatement, Printing in java is pretty much useless unless you can create your own framework, which you have to pretty much be a guru to create, but fortunately there was a nice guy, named Jean-Pierre Dube' who wrote an atricle for javaworld.com titled Printing in Java which provides a framework. It is really good. Initially I tried to print a JPanel and had the same problem as you, but then I read the article and used the framework and it did exactly what I wanted it to. I think what it does is take the programmed size (or preffered size) so if in your program you have specified the JPanel size (600,600) it will print it out in this size even if the person changes the size of the frame.
    Hope this helps and a big thanks to Jean-Pierre Dube'
    There are also a few other print Frameworks out there for free such as JFreeReport which is another good one, and I'd like to thank those guys if they happen to read this as well ( by the way, they made a post a few days ago stating a new version was out, and someone snubbed them by saying that this was not the place for advertising, but I think it is great they let us know, nothing wrong with being informed of a good freeware, especially for stuff that makes up where java lags. Thanks guys at JFreeReport).
    Cheers, Oz!!!!

  • Printing in Java 1.4 - printJob.getGraphics() causes exception

    Hi,
    I'm trying to print (using java 1.4) however the code
    'printJob.getGraphics()' (where printJob is a PrintJob object) seems to cause an exception (see below..)
    Could anyone please tell me a bit more about what this exception means?
    Thanks a lot!
    Kat
    Here's the exception:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D0844C6
    Function=Java_sun_awt_windows_WPrinterJob_setNativePrintService+0x19D
    Library=C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\awt.dll
    Current Java thread:
    at sun.awt.windows.WPrinterJob.setNativePrintService(Native Method)
    at sun.awt.windows.WPrinterJob.setPrintService(WPrinterJob.java:384)
    at sun.print.RasterPrinterJob.getPrintService(RasterPrinterJob.java:354)
    at sun.awt.windows.WPrinterJob.getPrintService(WPrinterJob.java:408)
    at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:997)
    at sun.print.PrintJob2D.run(PrintJob2D.java:529)
    at java.lang.Thread.run(Thread.java:536)
    Dynamic libraries:
    0x00400000 - 0x00406000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\bin\java.exe
    0x77F50000 - 0x77FF9000 C:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F45000 C:\WINDOWS\system32\kernel32.dll
    0x77DD0000 - 0x77E5B000 C:\WINDOWS\system32\ADVAPI32.dll
    0x77CC0000 - 0x77D35000 C:\WINDOWS\system32\RPCRT4.dll
    0x77C10000 - 0x77C63000 C:\WINDOWS\system32\MSVCRT.dll
    0x6D330000 - 0x6D45C000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\client\jvm.dll
    0x77D40000 - 0x77DCD000 C:\WINDOWS\system32\USER32.dll
    0x77C70000 - 0x77CB0000 C:\WINDOWS\system32\GDI32.dll
    0x76B40000 - 0x76B6C000 C:\WINDOWS\System32\WINMM.dll
    0x76390000 - 0x763AA000 C:\WINDOWS\System32\IMM32.DLL
    0x629C0000 - 0x629C8000 C:\WINDOWS\System32\LPK.DLL
    0x72FA0000 - 0x72FFA000 C:\WINDOWS\System32\USP10.dll
    0x6D1D0000 - 0x6D1D7000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\hpi.dll
    0x6D300000 - 0x6D30D000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\verify.dll
    0x6D210000 - 0x6D229000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\java.dll
    0x6D320000 - 0x6D32D000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\zip.dll
    0x6D260000 - 0x6D27C000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\jdwp.dll
    0x501D0000 - 0x501D5000 C:\JBuilder4\jdk1.3\bin\dt_socket.dll
    0x71AB0000 - 0x71AC5000 C:\WINDOWS\System32\ws2_32.dll
    0x71AA0000 - 0x71AA8000 C:\WINDOWS\System32\WS2HELP.dll
    0x71A50000 - 0x71A8B000 C:\WINDOWS\System32\mswsock.dll
    0x76F20000 - 0x76F45000 C:\WINDOWS\System32\DNSAPI.dll
    0x76FB0000 - 0x76FB7000 C:\WINDOWS\System32\winrnr.dll
    0x76F60000 - 0x76F8C000 C:\WINDOWS\system32\WLDAP32.dll
    0x76FC0000 - 0x76FC5000 C:\WINDOWS\System32\rasadhlp.dll
    0x71A90000 - 0x71A98000 C:\WINDOWS\System32\wshtcpip.dll
    0x6D000000 - 0x6D0FA000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\awt.dll
    0x73000000 - 0x73023000 C:\WINDOWS\System32\WINSPOOL.DRV
    0x771B0000 - 0x772CA000 C:\WINDOWS\system32\ole32.dll
    0x5AD70000 - 0x5ADA4000 C:\WINDOWS\system32\uxtheme.dll
    0x6D180000 - 0x6D1D0000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\fontmanager.dll
    0x51000000 - 0x51044000 C:\WINDOWS\System32\ddraw.dll
    0x73BC0000 - 0x73BC6000 C:\WINDOWS\System32\DCIMAN32.dll
    0x6D910000 - 0x6D981000 C:\WINDOWS\System32\D3DIM.DLL
    0x210F0000 - 0x21114000 C:\WINDOWS\System32\Hook98.dll
    0x6D2A0000 - 0x6D2C1000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\jsound.dll
    0x72D20000 - 0x72D29000 C:\WINDOWS\System32\wdmaud.drv
    0x72D10000 - 0x72D18000 C:\WINDOWS\System32\msacm32.drv
    0x77BE0000 - 0x77BF4000 C:\WINDOWS\System32\MSACM32.dll
    0x77BD0000 - 0x77BD7000 C:\WINDOWS\System32\midimap.dll
    0x6D130000 - 0x6D152000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\dcpr.dll
    0x6D100000 - 0x6D123000 C:\Program Files\s1studio_jdk\j2sdk1.4.1\jre\bin\cmm.dll
    0x763B0000 - 0x763F5000 C:\WINDOWS\system32\COMDLG32.DLL
    0x772D0000 - 0x77333000 C:\WINDOWS\system32\SHLWAPI.dll
    0x77340000 - 0x773CB000 C:\WINDOWS\system32\COMCTL32.dll
    0x69800000 - 0x69FEE000 C:\WINDOWS\system32\SHELL32.dll
    0x71950000 - 0x71A34000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a\comctl32.dll
    0x21F10000 - 0x21F17000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBF0010.DLL
    0x21F30000 - 0x21FA4000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBF0016.dll
    0x21FB0000 - 0x21FC0000 C:\WINDOWS\System32\MSVCIRT.dll
    0x21FC0000 - 0x220D2000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBF0013.DLL
    0x220E0000 - 0x220FE000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBF0011.DLL
    0x77C00000 - 0x77C07000 C:\WINDOWS\system32\VERSION.dll
    0x6E680000 - 0x6E6B9000 C:\WINDOWS\System32\COMPSTUI.dll
    0x76380000 - 0x76385000 C:\WINDOWS\System32\MSIMG32.dll
    0x22100000 - 0x2210F000 C:\WINDOWS\System32\spool\DRIVERS\W32X86\2\HPBAFD32.DLL
    0x76C90000 - 0x76CB2000 C:\WINDOWS\system32\imagehlp.dll
    0x6D510000 - 0x6D58C000 C:\WINDOWS\system32\DBGHELP.dll
    0x76BF0000 - 0x76BFB000 C:\WINDOWS\System32\PSAPI.DLL
    Local Time = Tue Feb 18 15:37:46 2003
    Elapsed Time = 22
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.1-b21 mixed mode)
    # An error report file has been saved as hs_err_pid3640.log.
    # Please refer to the file for further information.

    I have this problem, too. I have seen numerous references to it in the forum, but no solution - not even something to try! I have tried printing to the same printer using an HP LaserJet III driver and had success, but then IT ALSO STARTED GETTING THE SAME EXCEPTION!!! The same code on another PC has no errors and runs every time. We are comparing to see what the difference is between the two machines in hopes of finding a solution. But the one that fails worked yesterday! We really could use some help on this one...

  • Send a txt file to the printer with java

    Hello,
    I want to sent a txt file to the printer in java. I' am using the USB port. I can try to setup a dos command (print c:\test.txt), but I don't know the exactly command.
    There is also another solution in java I thing but I don't know the code!
    Can somebody give me the exact command for DOS and/or the code I have to write in java?
    THANX!!!!

    in dos imo you are not able to use usb-port. if your printer would be on lpt you could use javacomm ( http://java.sun.com/products/javacomm/index.html ). there is also another thread talking about this (print text to lpt). for your usb-problem i don't have a solution. but you could use JNI (java native interface). write code in c, compile to dll and use it in java.
    tobias
    ps: the other thread ( http://forum.java.sun.com/thread.jsp?forum=31&thread=224460 )

  • 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.

  • Warning Noob: Sending "Hello World!" in Printer using Java Applet

    Hello guys!
    im a newbie in java programming... i hope that you can help me with my problem.
    how can i print "Hello World!" in printer using java applet. lets pretend that the applet is digitally signed.
    i tried window.print in javascript but unfortunately, that is not what i am looking for.
    thanks for reading my post and i hope that you help me with my quest in java =)

    An applet is still part of the Swing package. I assume you're extending JApplet. There isn't anything in the print API that says it can't be done in an applet. Except that you might have to sign your applet Jar file with a digital certificate to get the printing to work.

  • Questions About Printing in Java

    Alright, I've been looking at the Java printing API. I like it, it's nice. I've got a drag-and-drop workspace that the user wants to print, so I just use m_workspace.paint(Graphics) on the print Graphics object to paint the workspace onto the page. Very nice.
    Here's the issue. I want to fit as many workspaces on a page as is possible. Now, with a Graphics2D object, I can call a couple of methods to get its height and width. I need to be able to determine the height and width of the Graphics object that the printer hands me. Here are the questions as best as I can describe them:
    * Is it possible to find the height and width of a Graphics object? How else can you determine a Graphics object's coordinate range?
    * When the Printable interface is given a Graphics object on which to print, does the Graphcis object represent the whole page or just the printable area of the page?
    * The PageFormat class provides methods for determining the height and width as well as the printable height and width of a page in 72nds of an inch. How does one determine the intended printing resolution (dpi) of the print job? If this cannot be done, how is it possible to determine the size of the page in pixels?
    I'd really appreciate help with this as fast as it can be mustered. This program needs to be completed by Friday morning and I'm clueless as to the Java printing interface.
    Thanks for any time you've spent reading this and the time you may spend answering it. :) Best wishes!

    After perusing the many books of one of my coworkers, I think I have good reason to believe the following:
    * Printing with the Printable interface is always at a resolution of 72dpi (1 pixel per point).
    * The Graphics object passed to print(...) represents a pixel space equal to the number of points of each dimension of the imageable area of the page.
    Can anyone with experience with Java printing confirm these conclusions?

  • How to print an Doc file(MS Word File)on a printer in JAVA

    Hi.I am Prakash.
    Folowing is the code that i have used to print an doc file on a printer. Problem is that , when i run this code it will provide me an printout of a doc file.,but not in well formate as the actual formate of the file. If any one tried this before plz help me.Thanks
    import java.lang.reflect.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Graphics2D;
    import java.io.*;
    import javax.swing.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.print.event.*;
    public class BasicPrint {
         JFrame frame;
         JButton btn;
         private boolean PrintJobDone = false;
         protected void MakeGui() {
              frame = new JFrame("PrintService");
              btn = new JButton("Cancel Print Job");
              btn.disable();
              frame.getContentPane().add(btn, BorderLayout.SOUTH);
              frame.pack();
              frame.setVisible(true);
         BasicPrint(String FileToPrint, String pMode) {
              try {
                   MakeGui();
                   File baseDir = new File("d:/doc");
    File outDir = new File(baseDir, FileToPrint);
                   // Open the image file
                   InputStream is = new BufferedInputStream(new FileInputStream(
                             outDir));
                   // Find the default service
                   DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                   //DocFlavor flavor = new DocFlavor("application/msword", "java.io.InputStream");
                   //DocFlavor docFlavor = new DocFlavor("application/vnd.ms-word", "java.io.InputStream");
                   if (pMode != null && pMode.equalsIgnoreCase("PS"))
                        flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
                   else if (pMode != null && pMode.equalsIgnoreCase("PDF"))
                        flavor = DocFlavor.INPUT_STREAM.PDF;
                   else if (pMode != null && pMode.equalsIgnoreCase("JPG"))
                        flavor = DocFlavor.INPUT_STREAM.JPEG;
                   else if (pMode != null && pMode.equalsIgnoreCase("GIF"))
                        flavor = DocFlavor.INPUT_STREAM.GIF;
                   else if (pMode != null && pMode.equalsIgnoreCase("PNG"))
                        flavor = DocFlavor.INPUT_STREAM.PNG;
                   else if (pMode != null && pMode.equalsIgnoreCase("PCL"))
                        flavor = DocFlavor.INPUT_STREAM.PCL;
                   else if (pMode != null && pMode.equalsIgnoreCase("RAW"))
                        flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                   else if (pMode != null && pMode.equalsIgnoreCase("TXT16"))//****                                   *********
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16;
                        System.out.println("****ACTIVE***");
                   else if (pMode != null && pMode.equalsIgnoreCase("TXTBE"))//****
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16BE;
                   else if (pMode != null && pMode.equalsIgnoreCase("TXTHOST"))//***
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST;
                   else if (pMode != null && pMode.equalsIgnoreCase("TXT8"))
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
                   else if (pMode != null && pMode.equalsIgnoreCase("TXTASCI"))
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII;
                   else if(pMode != null && pMode.equalsIgnoreCase("TXTLE"))
                        flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16LE;                                        //*******
                   else if(pMode != null && pMode.equalsIgnoreCase("SEVICE"))
                        flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
                   String type = flavor.getMediaType();
                   System.out.println("Type ="+ type);
                   //IMPRIMIR prakashCV.doc TXT text/plain; charset="utf-16le"; class="java.io.InputStream"
                   System.err.println("* IMPRIMIR " + FileToPrint + " " + pMode + " "
                             + flavor);
                   PrintService dservice = PrintServiceLookup
                             .lookupDefaultPrintService();
                   PrintService[] services = PrintServiceLookup.lookupPrintServices(
                             flavor, null);
                   if (services == null || services.length < 1)
                        services = PrintServiceLookup.lookupPrintServices(null, null);
                   PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                   aset.add(new Copies(1));
                   aset.add(OrientationRequested.PORTRAIT);
                   // aset.add(MediaTray.MAIN);
                   aset.add(Sides.ONE_SIDED);
                   aset.add(MediaSizeName.ISO_A4);
                   PrintService service = ServiceUI.printDialog(
                             (GraphicsConfiguration) null, 60, 60, services,
                             (PrintService) dservice, (DocFlavor) flavor, aset);
                   if (service != null) {
                        // Create the print job
                        final DocPrintJob job = service.createPrintJob();
                        Doc doc = new SimpleDoc(is, flavor, null);
                        // Monitor print job events; for the implementation of
                        // PrintJobWatcher,
                        PrintJobWatcher pjDone = new PrintJobWatcher(job);
                        if (job instanceof CancelablePrintJob) {
                             btn.addActionListener(new ActionListener() {
                                  public void actionPerformed(ActionEvent evt) {
                                       CancelablePrintJob cancelJob = (CancelablePrintJob) job;
                                       try {
                                            cancelJob.cancel();
                                       } catch (PrintException e) {
                                            // Possible reason is job was already finished
                             btn.enable();
                        try {
                             // Print it
                             job.print(doc, (PrintRequestAttributeSet) aset);
                        } catch (PrintException e) {
                             e.printStackTrace();
                        System.err.println("* Impresion Realizada - Esperando ..");
                        // Wait for the print job to be done
                        pjDone.waitForDone();
                   // It is now safe to close the input stream
                   is.close();
              } catch (IOException e) {
                   e.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
              } finally {
                   try {
                        synchronized (BasicPrint.this) {
                             PrintJobDone = true;
                             BasicPrint.this.notify();
                   } catch (Exception e) {
                        e.printStackTrace();
         public synchronized void waitForDone() {
              try {
                   while (!PrintJobDone) {
                        wait();
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public static void main(String[] args) {
              try {
                   //args[0]="t";
                   //args[1]="rr";
    //               if (args.length < 1) {
    //                    System.err.println("\nSintaxis:\n\n java BasicPrint FileToPrint [pMode]\n");
    //                    System.exit(0);
                   BasicPrint bp = null;
                   //if (args.length < 2){
                        //bp = new BasicPrint(args[0], null);
                   //}else{
                        //bp = new BasicPrint(args[0], args[1]);
                        bp = new BasicPrint("prakashCV.doc","SEVICE");                                                       //****/***
                   bp.waitForDone();
                   System.exit(0);
              } catch (Exception e) {
                   e.printStackTrace();
         class PrintJobWatcher {
              // true iff it is safe to close the print job's input stream
              boolean done = false;
              int lastEvent = 0;
              PrintJobWatcher(DocPrintJob job) {
                   // Add a listener to the print job
                   job.addPrintJobListener(new PrintJobAdapter() {
                        public void printJobRequiresAttention(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err
                                       .println("* La impresora requiere de su Atencion ! * "
                                                 + pje);
                             // allDone();
                        public void printDataTransferCompleted(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err
                                       .println("* Transferencia de datos a la impresora OK. * "
                                                 + pje);
                             // allDone();
                        public void printJobCanceled(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err.println("* Trabajo de impresion CANCELADO ! * "
                                       + pje);
                             allDone();
                        public void printJobCompleted(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err.println("* Impresion completa OK. * " + pje);
                             allDone();
                        public void printJobFailed(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err.println("* ERROR en la Impresion ! * " + pje);
                             // allDone();
                        public void printJobNoMoreEvents(PrintJobEvent pje) {
                             lastEvent = pje.getPrintEventType();
                             System.err
                                       .println("* No mas eventos de impresion * " + pje);
                             allDone();
                        void allDone() {
                             synchronized (PrintJobWatcher.this) {
                                  done = true;
                                  PrintJobWatcher.this.notify();
              /** Description of the Method */
              public synchronized void waitForDone() {
                   try {
                        while (!done) {
                             wait();
                   } catch (InterruptedException e) {
                        e.printStackTrace();
    }

    Hi Maxpkh
    Do you mean attachment? You can't do that with free Adobe Reader you need Acrobat to do this.
    ~Deepak

Maybe you are looking for

  • On iPhone 5 (iOS 7), calendar alerts are 'deleted' after event occurs

    This seems to be new(ish) behavior and is increasing in frequency. I have an iPhone 5 and am on iOS7. Outlook is my default calendar. (I have already checked all my settings related to alerts; that isn't the issue.) What's happening is this: I set a

  • Org unit of a position

    Hi all, I want to find out the organizational unit for the given position in OM. Also, i want to find out the manager of this position. Any solution....? Regards, Shanthi

  • What changed in iOS 7 that will not allow me to add audiobook files into a playlist?

    In iOS 6 on my phone I could create a playlist and had the option to add audiobook files.  This feature is gone in iOS 7.  How can I do this without using iTunes to create and manage the playlist?  This was a feature I used often in iOS 6 to manage m

  • Oracle Business Rules!!

    Hi all, Is there any option in 11g SOA Suite where i can create rules in a webbrowser like "Rules Author " option in 10g? i m also aware of SOA Composer..but using soa composer is it possible to create rules at design time? any suggestions? Thanks, k

  • Strange Index and Search behavior

    Hello, When the WebHelp I've created is viewed in Firefox 2.0 and Safari on a Mac, the Search button does not reveal a search box, but instead looks like an index, with some of the words followed by numbers, and some words in bold text. This does not