简体   繁体   English

在 Java 中使用 ipp 将 PDF 文件发送到网络打印机

[英]Send PDF file to network printer using ipp in Java

I'm using the below code to send pdf file into network printer.我正在使用以下代码将 pdf 文件发送到网络打印机。
The command is send but file not print actual data.命令发送但文件不打印实际数据。
Please help me.请帮我。

String urlF="ipp://192.168.0.115:9100/printer/TOSHIBA e-STUDIO2802ASeries PCL6";
                String urlS=urlF.replaceAll(" ", "%20");
                URI printerURI = new URI(urlS);
                IppPrintService svc = new IppPrintService(printerURI);
                stream = new BufferedInputStream(new FileInputStream("D:/pdfurl-guide.pdf"));
                DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                Doc myDoc = new SimpleDoc(stream, flavor, null);
                DocPrintJob job = svc.createPrintJob();
                job.print(myDoc, null);

Your printer model doesn't seem to support what you are trying to do.您的打印机型号似乎不支持您尝试执行的操作。

  1. PDL: PDF not supported PDL:不支持 PDF
  2. protocol: no IPP support (default port ist 631)协议:不支持 IPP(默认端口 ist 631)

In case the used ipp implementation has good error handling you should see some kind of error message or exception, when you run the code.如果使用的 ipp 实现具有良好的错误处理能力,您应该在运行代码时看到某种错误消息或异常。

UPDATE更新

Using this ipp-client you can submit a PDF file to a printer (or CUPS) that supports this document format:使用此ipp-client ,您可以将 PDF 文件提交到支持此文档格式的打印机(或 CUPS):

new IppPrinter(URI.create("ipp://myprinter")).printJob(
    File("mydocument.pdf"), documentFormat("application/pdf")
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM