如何在Processing中简单地打印一页?
对于我当前的项目,我正在寻找一种非常简单的解决方法。我在处理中制作随机图形,当代码完成图形后,它应该在我的打印机上打印。但最好没有对话框等。只需将其打印在纸上即可。
我浏览了互联网和几个 Java 论坛,但我只找到了“矫枉过正”的教程。 (像这样: http://www.javaworld.com /javaworld/jw-10-2000/jw-1020-print.html)
有一个简单的方法来做到这一点吗?
for my current project, I'm looking for a really simple workaround. I do a random graphic in Processing, and when the code has finished the graphic it should print on my printer. But preferable without the dialog etc. Just print it on paper.
I was looking around the Internet and several Java forums, but I only found "overkill" tutorials. (like this: http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html)
Is there an easy way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我听说过有关 GDSPrinting 的好消息。虽然我没有使用过它,并且根据该页面,它的版本是 0.2,但它可能是适合您的解决方案。
正如之前多次说过的那样:Java 和打印机相处得不太好。
祝你好运。
I've heard good things about GDSPrinting. While I've not used it and according to that page it's version 0.2, it may be a solution for you.
As has been said too many times before: Java and Printers don't get along very well.
I wish you luck.
这绝对是一种黑客攻击,但如果您找不到所需的内容,请编写脚本截取屏幕截图(键盘命令)并打开照片编辑器并打印。 http://sikuli.org/ 可以自动按下按钮(如打印),并且您可以使用 open 从处理中执行外部命令()
http://processing.org/reference/open_.html
http://sikuli.org/docx/faq/010-command-line.html
This is definitely a hack, but if you can't find what you're looking for, script taking a screenshot (keyboard command) and open a photo editor and print. http://sikuli.org/ can automate pressing buttons (like print) and you can execute external commands from Processing using open()
http://processing.org/reference/open_.html
http://sikuli.org/docx/faq/010-command-line.html
如果没有简单的方法直接调用打印机,您可以使用java Robot类,这里有一个如何使用它的示例:如何在java中模拟键盘按下?
If there is no easy way to directly call the printer, you may use the java Robot class, here is an example on how to use it: How to simulate keyboard presses in java?
我晚了 8 年才回答这个问题,但希望它对找到这个帖子的人有所帮助。
首先使用明确的路径保存要打印的图像/帧:
然后将此方法添加到您的草图中:
现在只需使用相关的文件名和路径调用该方法:
这相当于在命令行界面中运行以下命令:
这是中等帖子解释了这一点。
I'm answering this 8 years late, but hopefully it helps anyone who finds this thread.
First save the image / frame that you want to print with a definite path:
Then add this method to your sketch:
Now just call the method with the relevant filename and path:
It's the equivalent of running the following in your command line interface:
Here's a medium post explaining this.