Emergency javax.print question ---- who can help me?? thank in advance.

Discussion in 'Java' started by Ken, Jan 26, 2004.

  1. Ken

    Ken Guest

    I'm working with the JDK 1.4.2_01-b02 on XP. I try to print out my log
    file.

    Here is my printer's return information:
    image/gif; image; [B
    image/gif; image; java.io.InputStream
    image/gif; image; java.net.URL
    image/jpeg; image; [B
    image/jpeg; image; java.io.InputStream
    image/jpeg; image; java.net.URL
    image/png; image; [B
    image/png; image; java.io.InputStream
    image/png; image; java.net.URL
    application/x-java-jvm-local-objectref; application;
    java.awt.print.Pageable
    application/x-java-jvm-local-objectref; application;
    java.awt.print.Printable
    application/octet-stream; application; [B
    application/octet-stream; application; java.net.URL
    application/octet-stream; application; java.io.InputStream

    Here is my code:
    try {
    FileInputStream textStream = new FileInputStream("C:/my.log");
    DocFlavor textInFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
    Doc textDoc = new SimpleDoc(textStream, textInFormat, null);
    PrintService printer =
    PrintServiceLookup.lookupDefaultPrintService();
    DocPrintJob job = printer.createPrintJob();
    job.print(textDoc, null);
    } catch (Exception e) {e.printStackTrace();}

    Here is the content of my.log file:
    "Testing javax.print"

    Here is the situation:
    1. I can print out JPEG file with this javax.print API.
    2. I can see my.log appear in the printer's job queue and indicate it
    was printed out successfully.
    3. But in fact printer didn't act! (If I print JPEG, it works)
    4. I even try this way:
    "Doc strDoc = new SimpleDoc("OK!", DocFlavor.STRING.TEXT_PLAIN,
    null);"
    But error message has been throwed out:
    "sun.print.PrintJobFlavorException: invalid flavor"


    Any help appreciate!!


    Ken
     
    Ken, Jan 26, 2004
    #1
    1. Advertising

  2. Andrew Thompson, Jan 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arun Kumar Srinivasan

    Using javax.print classes to print text/file

    Arun Kumar Srinivasan, Jan 13, 2004, in forum: Java
    Replies:
    5
    Views:
    6,255
    Gregory A. Swarthout
    Jan 14, 2004
  2. hiwa
    Replies:
    1
    Views:
    1,179
    Thomas Weidenfeller
    Mar 9, 2005
  3. Replies:
    1
    Views:
    803
    Esmond Pitt
    Mar 27, 2005
  4. lizard
    Replies:
    0
    Views:
    1,799
    lizard
    Jan 30, 2006
  5. Pascal
    Replies:
    0
    Views:
    431
    Pascal
    Oct 24, 2008
Loading...

Share This Page