Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 08:27 PM
Member
 
Join Date: Feb 2009
Posts: 21
Rep Power: 0
pinks_70986 is on a distinguished road
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);
}
}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-11-2009, 10:13 PM
makpandian's Avatar
Senior Member
 
Join Date: Dec 2008
Location: Chennai
Posts: 253
Rep Power: 2
makpandian is on a distinguished road
Default
i could not understand what you are trying to say
__________________
Mak
(Living @ Virtual World)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-12-2009, 04:26 PM
Member
 
Join Date: Feb 2009
Posts: 21
Rep Power: 0
pinks_70986 is on a distinguished road
Default
hii my problem is solved
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i save file with greek word? mailbankey Eclipse 0 04-15-2009 02:16 PM
Count lines cointaining "word" in input file gwithey New To Java 5 04-02-2009 06:23 AM
Display MS-Word file in browser jazz2k8 Advanced Java 6 12-08-2008 01:59 PM
Search a word(taken from one file) in another file and give the line as the output SwapnaNaidu New To Java 7 11-19-2008 03:09 PM
copying file from a email/word to a Java application cmbl Advanced Java 13 01-09-2008 07:51 AM


All times are GMT +2. The time now is 05:53 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org