1

Mac OS X 10.8.0 で以下の Java コードを含む JPEG ファイルを印刷しようとすると、次のエラー メッセージが表示されます。

Error: pstopdffilter/pstocupsraster failed with err number 31000

Google で検索すると、問題が Java に直接関係していないことを示唆するような提案が表示されます (例: http://forum.parallels.com/showthread.php?t=106337 )。

/**
 * http://stackoverflow.com/questions/7843338/printing-a-tif-file
 * 
 * @param graphicFile
 * @throws PrintException
 * @throws IOException
 */
public void printGraphic(File graphicFile) throws PrintException,
        IOException {

    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    pras.add(new Copies(1));
    pras.add(Chromaticity.COLOR);
    pras.add(MediaSizeName.ISO_A4);
    PrintService pss[] = PrintServiceLookup.lookupPrintServices(
            DocFlavor.INPUT_STREAM.JPEG, 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();
    FileInputStream fin = new FileInputStream(graphicFile);
    Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.JPEG, null);
    job.print(doc, pras);
    fin.close();
}
4

2 に答える 2

2

回避策として、tiff の代わりに jpeg を使用することをお勧めします。

/**
 * http://stackoverflow.com/questions/5338423/print-a-image-with-actual-size
 * -in-java
 * 
 * @param graphicFile
 */
public void printG(File graphicFile) {
    final Image img = new ImageIcon(graphicFile.getAbsolutePath())
            .getImage();
    PrinterJob printJob = PrinterJob.getPrinterJob();
    Printable printable = new Printable() {
        public int print(Graphics graphics, PageFormat pageFormat,
                int pageIndex) throws PrinterException {
            if (pageIndex != 0) {
                return NO_SUCH_PAGE;
            }
            graphics.drawImage(img, 0, 0, img.getWidth(null),
                    img.getHeight(null), null);
            return PAGE_EXISTS;
        }
    };
    printJob.setPrintable(printable, getPageFormat());
    if (printJob.printDialog()) {
        try {
            printJob.print();
        } catch (Exception prt) {
            handle(prt);
        }
    }
}
于 2012-10-19T07:20:09.257 に答える
1

あなたは「JPEGファイルを印刷しようとしている」と言います。

ただし、エラー メッセージは、CUPS (Mac OS X 印刷サブシステム) がpstopdffilter(PostScript を PDF に変換するユーティリティ) またはpstocupsraster(PostScript を CUPS-raster に変換するユーティリティ) を介して印刷ジョブを実行しようとしていることを示しています。

最初に有効にする必要があります( /private/etc/cups/cupsd.confLogLevel debugを編集し、CUPS 印刷サービスを再起動します)。

次に、CUPS ログ ファイル (*/var/log/cups/error_log*) で、次の文字列を含む行を探します。

Auto-typing file...
Request file type is
Started filter
Started backend
exited with
failed with

調査結果次のようになります。

D [...timestamp...] [Job 9] Auto-typing file...
D [...timestamp...] [Job 9] Request file type is image/jpeg.
I [...timestamp...] [Job 9] Started filter /usr/libexec/cups/filter/imagetops (PID 25690)
I [...timestamp...] [Job 9] Started filter /usr/libexec/cups/filter/pstops (PID 25691)
I [...timestamp...] [Job 9] Started filter /usr/libexec/cups/filter/pstopdffilter (PID 25694)
I [...timestamp...] [Job 9] Started backend /usr/libexec/cups/backend/2dir (PID 25695)
D [...timestamp...] PID 25690 (/usr/libexec/cups/filter/imagetops) exited with no errors.
D [...timestamp...] PID 25691 (/usr/libexec/cups/filter/pstops) exited with no errors.
E [...timestamp...] PID 25694 (/usr/libexec/cups/filter/pstopdffilter) failed with err number -31000.
D [...timestamp...] PID 25695 (/usr/libexec/cups/backend/2dir) exited with no errors.

私のクリスタル ボールは現在修理中で、印刷環境のセットアップに関する追加の詳細を提供していないため、「次のような」と言いました。これがないと、問題をこれ以上分析することはできませ

また、ログ ファイルで PostScript エラーを示す行を探します。次に例を示します。

D [...timestamp...] [Job 9] %%[ Error: ioerror; OffendingCommand: image ]%%
D [...timestamp...] [Job 9] 
D [...timestamp...] [Job 9] Stack:
D [...timestamp...] [Job 9] -dict-
D [...timestamp...] [Job 9] 
D [...timestamp...] [Job 9] %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
D [...timestamp...] [Job 9] 
D [...timestamp...] [Job 9] %%[ Warning: PostScript error. No PDF file produced. ] %%

その場合、入力ファイルに問題があるか、大きすぎるか、またはその他の可能性があります...

一般に、次のことを知っておくことが重要です。

  1. 印刷サービスの「自動入力」機能は、印刷ジョブの MIME タイプに対して何を返しましたか?
  2. pstopdffilter (または pstocupsraster) が機能する前に、フィルター チェーンで実行されていたフィルター (存在する場合) は何ですか?
于 2012-10-19T08:33:19.380 に答える