what DocFlavor shall I use when I want to print string?

Here is some of my code :

java.lang.String printStr = new String("222222222222222222");

DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;

Doc doc = new SimpleDoc(printStr, flavor, das);

when I run this code , the following error occured:

Error 500--Internal Server Error

java.lang.IllegalArgumentException: data is not of declared type

at javax.print.SimpleDoc.(SimpleDoc.java:82)

this means I chose a wrong DocFlavor,

what DocFlavor sould I use , please give me valuable suggestions, Thanks a lot.

[571 byte] By [longgger2000] at [2007-9-30 17:53:18]
# 1
someone help me?
longgger2000 at 2007-7-6 14:28:43 > top of Java-index,Java Essentials,Java Programming...
# 2

here is my code :

java.lang.StringprintStr = new String("222222222222222222");

if (printStr != null && printStr.length() > 0)

{

int PAGES = 1;

DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;

PrintService printService = PrintServiceLookup.lookupDefaultPrintService();

DocPrintJob job = printService.createPrintJob();

PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();

DocAttributeSet das = new HashDocAttributeSet();

Doc doc = new SimpleDoc(printStr, flavor, das);

job.print(doc, pras);

}

Please tell me how to solve this problem!

Thank you

longgger2000 at 2007-7-6 14:28:43 > top of Java-index,Java Essentials,Java Programming...
# 3

The DOC_FLAVOR you should use is one that's supported by your printer. It's not determined just by what you're printing, it's the destination, too.

Try DocFlavor.INPUT_STREAM.AUTOSENSE.

You'll want to read this, too:

http://www-106.ibm.com/developerworks/java/library/j-mer0322/

http://www-106.ibm.com/developerworks/java/library/j-mer0424.html

%

duffymo at 2007-7-6 14:28:43 > top of Java-index,Java Essentials,Java Programming...
# 4
thank you, duffymo, for providing useful information , I will follow you suggestion .longgger2000
longgger2000 at 2007-7-6 14:28:43 > top of Java-index,Java Essentials,Java Programming...