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