0

次のコードスニペットを使用して.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をサポートするにはどうすればよいですか?

4

1 に答える 1

1

TIFF用のJavaAdvancedImagingAPI使用します。JAIは、マルチページTIFFファイル、TIFFのJPEG、およびいくつかの圧縮スキームを処理できます。それでも印刷に問題がある場合は、APIを使用してTIFFファイルをPNGに変換できます。

于 2011-10-20T23:33:56.400 に答える