开发者

Print Txt file from Processing Sketch

开发者 https://www.devze.com 2023-03-18 10:10 出处:网络
I have a processing sketch that sends a String to a .txt file and then I want to be able to print the same .txt file from开发者_开发百科 the processing sketch.

I have a processing sketch that sends a String to a .txt file and then I want to be able to print the same .txt file from开发者_开发百科 the processing sketch.

Any ideas on how to do this?

I've thought about running a .bat file from the processing sketch using open() but my shell scripting skills are non-existent.

Thanks!


On windows:

Your idea about opening a console to do the work, since this is platform stuff, seems reasonable. However, if you have a USB printer it's tough.

Instead, I suggest you install Powershell (on Windows 7 you have it by default). The way you can print in Powershell is to get the contents of a file and shoot it to the Out-Printer (alias 'lp') cmdlet. Then your open call is:

String psPrint = "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -Command \"Get-Content " + filename + " | Out-Printer\"";
open(psPrint);

N.B. I haven't tried this in Processing, but the command line works for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号