打印.TIF文件 [英] Printing a .TIF file

查看:130
本文介绍了打印.TIF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码段成功打印.GIF,.JPG或.PNG,但不适用于.TIF文件.另外,即使添加chromaticity.color属性,我也无法获得颜色.

I am able to print a .GIF, .JPG or .PNG successfully using the following code snippet but it doesn't work for .TIF file. Also I can't get the color even after adding the chromaticity.color attribute.

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进行打印?

How do I support .TIF for printing?

推荐答案

使用用于TIFF的> Java Advanced Imaging API . JAI可以处理多页TIFF文件,TIFF中的JPEG和一些压缩方案.如果仍然无法打印,则可以使用API​​将TIFF文件转换为PNG.

Use Java Advanced Imaging API for TIFF. JAI can handle multipage TIFF files, JPEG in TIFF and a few compression schemes. If you still have trouble printing, with the API you could convert your TIFF file to PNG.

这篇关于打印.TIF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆