本文介绍了运行时exec lp命令打印成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在java程序中打印一个PDF文件并确保它打印成功,否则抛出异常.

I have to print a PDF file in java program and make sure it's printed successfully, else throw exception.

我的代码是:

Process p = Runtime.getRuntime().exec("lp -c -n 1 -d 1.2.3.4 abc.pdf");
System.out.println(p.waitFor());

上面的代码打印0,但它只确认作业提交正常,如何确保它也被打印.

Above code prints 0, but it only confirms that job is submitted fine, how to make sure that it's printed also.

有没有其他方法可以做到这一点?

Is there any other way to do this?

推荐答案

运行 lpstat(在 lp 之后)并捕获进程输出.

Run lpstat (after lp) and capture the process output.

这篇关于运行时exec lp命令打印成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 08:11