我可以使用以下代码片段成功打印 .GIF、.JPG 或 .PNG,但它不适用于 .TIF 文件。即使添加了chromaticity.color
属性,我也无法获得颜色。
public class PrintImage {
static public void main(String args[]) throws Exception {
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
pras.add(chromaticity.color);
PrintService pss[] = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF, pras);
if (pss.length == 0)
throw new RuntimeException("No printer services available.");
PrintService ps = pss[0];
System.out.println("Printing to " + ps);
DocPrintJob job = ps.createPrintJob();
String fileName = "C:/labels/2.tif"
FileInputStream fin = new FileInputStream(fileName);
Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.GIF, null);
job.print(doc, pras);
fin.close();
}
如何支持 .TIF 进行打印?