.
1) -, :
DocFlavor.STRING.TEXT_PLAIN;
:
"main" sun.print.PrintJobFlavorException:
, , :
public static final STRING TEXT_PLAIN =
new STRING ("text/plain; charset=utf-16");
, , , , .
, :
if (printer.getName().contains("ZM400")) {
String hello = "Hello";
DocFlavor flavor = DocFlavor.STRING.TEXT_PLAIN;
Doc doc = new SimpleDoc(hello, flavor, null);
job = printer.createPrintJob();
job.print(doc, null);
}
:
if (printer.getName().contains("ZM400")) {
Arrays.stream(printer.getSupportedDocFlavors()).forEach(f->System.out.println(f.getMediaType() + ":" + f.getMimeType() + ":" + f.getRepresentationClassName()));
String hello = "Hello";
DocFlavor flavor = DocFlavor.STRING.TEXT_PLAIN;
Doc doc = new SimpleDoc(hello, flavor, null);
job = printer.createPrintJob();
job.print(doc, null);
}
:
image: image/gif: [B : image/gif: java.io.InputStream
image: image/gif: java.net.URL image: image/jpeg: [B
image: image/jpeg: java.io.InputStream image: image/jpeg: java.net.URL
image: image/png: [B : /png: java.io.InputStream
: /PNG: java.net.URL
: /-Java-JVM- ObjectRef: java.awt.print.Pageable
: /-Java-JVM- ObjectRef: java.awt.print.Printable
: /-: [
: /-: java.net.URL
: /-: java.io.InputStream
, "text/plain; charset=utf-16".
2) DocFlavor.INPUT_STREAM.AUTOSENSE, - DocFlavor.
, , DocFlavor.INPUT_STREAM.AUTOSENSE .
, , DocFlavor.INPUT_STREAM.AUTOSENSE:
IllegalArgumentException: .
DocFlavor INPUT_STREAM.AUTOSENSE :
public static final INPUT_STREAM AUTOSENSE =
new INPUT_STREAM ("application/octet-stream");
:
: /-: java.io.InputStream
:
String hello = "Hello";
...
Doc doc = new SimpleDoc(hello, flavor, null);
InputStream, a String.
, , InputStream :
String hello = "Hello";
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc doc = new SimpleDoc(new ByteArrayInputStream(hello.getBytes()),
flavor, null);
:
: /-: [
InputStream, a String :
:
DocFlavor.BYTE_ARRAY.AUTOSENSE
:
String hello = "Hello";
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(hello.getBytes(), flavor, null);