I am facing difficulty when printing .txt file using javax.print.* . I am able to sucessfully print .gif, .jpeg..
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, April 26, 2004 10:50 PM

import java.io.*; import javax.print.*; import javax.print.attribute.*; import javax.print.attribute.standard.*; import javax.print.event.*; public class BasicPrint { public static void main(String ar[]) throws Exception { InputStream is = new BufferedInputStream (new FileInputStream("Sample.txt")); //InputStream is = new BufferedInputStream(new FileInputStream("Sample.gif")); PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); DocFlavor flavor =new DocFlavor.INPUT_STREAM("text/plain"); //DocFlavor flavor =new DocFlavor.INPUT_STREAM("image/gif"); //DocFlavor f   More>>
			
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;

public class BasicPrint
{

public static void main(String ar[]) throws Exception
{
InputStream is = new BufferedInputStream
(new FileInputStream("Sample.txt"));
//InputStream is = new BufferedInputStream(new FileInputStream("Sample.gif"));
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
DocFlavor flavor =new DocFlavor.INPUT_STREAM("text/plain");
//DocFlavor flavor =new DocFlavor.INPUT_STREAM("image/gif");
//DocFlavor
flavor =DocFlavor.INPUT_STREAM.INPUT_STREAM.AUTOSENSE;
PrintService service = PrintServiceLookup.lookupDefaultPrintService();

// Creating the print job
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(is, flavor, null);

// Printing it
DocPrintJob job = service.createPrintJob();
job.print(doc, null);
is.close();
}


}
   <<Less
About | Sitemap | Contact