Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Printing is still problem

Reply
Thread Tools

Printing is still problem

 
 
Mika Suomi
Guest
Posts: n/a
 
      03-04-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 2 11-27-2010 12:12 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57