Results 1 to 3 of 3
  1. #1
    pinks_70986 is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

    Default printin word file

    i have class which prints file. But i have refilled cartridge which sends out empty cartridge error when i manually print so i can press ok and continue. Here while printing through this class it aborts printing and gives message printing failed. how can i ignore cartridge empty error?
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.UIManager;

    import java.io.*;

    public class Printing {
    public void print(String filename) throws Exception
    {

    HashPrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; // MY FILE IS .txt TYPE
    PrintService printService[] =
    PrintServiceLookup.lookupPrintServices(flavor, pras);
    PrintService defaultService =
    PrintServiceLookup.lookupDefaultPrintService();
    PrintService service = ServiceUI.printDialog(null, 200, 200,
    printService, defaultService, flavor, pras);
    if (service != null) {
    DocPrintJob job = service.createPrintJob();
    FileInputStream fis = new FileInputStream(filename);
    try {
    // ServiceUI.setLookAndFeel("com.sun.java.swing.plaf. windows.WindowsLookAndFeel");
    } catch (Exception e) {
    JFrame frame=new JFrame();
    JOptionPane.showMessageDialog(frame,e.getMessage() , "ERROR",JOptionPane.ERROR_MESSAGE);
    System.exit(0);
    }


    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(fis, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
    }
    //System.exit(0);
    }
    }

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    431
    Rep Power
    6

    Default

    i could not understand what you are trying to say
    Mak
    (Living @ Virtual World)

  3. #3
    pinks_70986 is offline Member
    Join Date
    Feb 2009
    Posts
    18
    Rep Power
    0

Similar Threads

  1. How can i save file with greek word?
    By mailbankey in forum Eclipse
    Replies: 0
    Last Post: 04-15-2009, 01:16 PM
  2. Count lines cointaining "word" in input file
    By gwithey in forum New To Java
    Replies: 5
    Last Post: 04-02-2009, 05:23 AM
  3. Display MS-Word file in browser
    By jazz2k8 in forum Advanced Java
    Replies: 6
    Last Post: 12-08-2008, 12:59 PM
  4. Replies: 7
    Last Post: 11-19-2008, 02:09 PM
  5. Replies: 13
    Last Post: 01-09-2008, 06:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •