Printing is still problem

M

Mika Suomi

I ask earlier about printing....I don't get it work whatever I do. I explain
again. This code works but when I change the file to text-file and
INPUT_STREAM.AUTOSENSE or TEXT_PLAIN_US_ASCII or anything else it won't
work.

When I keep my printers window open and run program it shows that it's
printing but nothing comes out.

and there is an other thing : it will print text when the text is in the
code as a string.


import java.io.FileInputStream;
import java.io.FileNotFoundException;

import javax.print.*;

import javax.print.attribute.*;

import javax.print.attribute.standard.*;





public class PrintToPaper {



private FileInputStream text;



public PrintToPaper()

{



}

public void Print(){

try{

text=new FileInputStream("G:\\Work\\Java\\62.gif");

}

catch(FileNotFoundException e){

}

if(text==null){

return;

}

DocFlavor myFormat = DocFlavor.INPUT_STREAM.GIF;

Doc MyDoc = new SimpleDoc(text, myFormat, null);

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

aset.add(new Copies(1));

aset.add(MediaSizeName.ISO_A4);

aset.add(Sides.ONE_SIDED);

PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();

DocPrintJob job = pservice.createPrintJob();

try {

job.print(MyDoc,aset);

}

catch (PrintException e) {

System.err.println(e);

}}}



I'm desperate why it doesn't work.I hope somebody have heard something like
this or maybe somebody have had problem like this.....



Mika Suomi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top