从命令行打印图像,等待在Windows上完成打印作业
我需要编写一个解决方案来写入数据,然后打印RFID标签en-masse,每个标签都是从模板python脚本中生成的.png映像,以及从数据库或Excel文件中获取的数据。
要打印程序,只需使用subprocess.check_call(print_cmd)
传递image文件(现在保存在Ram-abounted文件系统上,用于最小磁盘使用),现在使用subprocess.check_call(print_cmd)调用相对系统实用程序(unix Systems上的杯子)
,现在它还需要在Windows系统上运行,但是实际上并没有一个不错的系统实用程序,并且在类似问题下解决方案命令行工具工具对于打印图片吗?不考虑打印作用的完成,或者如果作业导致错误,由于某种原因,将拧紧边距,并且图像始终旋转90度。
我如何使用Windows中的命令或脚本在Windows中打印图像并等待成功完成或返回错误(如果作业会导致错误)? 可能没有依赖关系
I needed to write a solution to write data on and then print RFID labels en-masse, each generated as .png images from a template python script and data taken from a database or excel file.
To print the program simply calls the relative system utility (CUPS on unix systems) using subprocess.check_call(print_cmd)
passing the image file (saved on a ram-mounted file system for minimal disk usage)
Now, it also needs to run on Windows systems, but there is not really a decent system utility for that, and solutions under a similar question command line tool for print picture? don't account for print-job completion or if the job results in an error, the margins are all screwed and the image is always rotated 90 degrees for some reason.
How can I sanely print an image using a command or a script in Windows and wait for it to complete successfully or return an error if the job results in an error?
Possibly with no dependencies
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您可以安装依赖项,则有许多程序提供解决方案。
我可以找到解决此问题的唯一理智的方法没有依赖关系是创建一个powershell脚本来解释
这
一点设置步骤:(
所以我不知道应该如何称呼英语thig。
转到打印机设置,然后在工具下进行编辑打印机状态监视
假设以下内容:
这个小小的黑客将通过错误管理打印命令和等待作业的图像,并且只能使用Windows预装的软件
来进一步优化path \ to \ print.ps1“” c:\ absolute \ path \ to \ file.png“ 格式,等待标准输出报告确定或ko;但仅在需要质量打印时。
If you can install dependencies, there are many programs that offer a solution out-of-the-box.
The only sane way i could find to solve this issue with no dependencies is by creating a powershell script to account for this
I would then need to slightly modify the print subprocess call to
Then there are a couple of necessary setup steps:
(discaimer, I don't use windows in english so i don't know how the english thigs are supposed to be called. i will use cursive for those)
create an example image, right click and then select Print
Go to printer settings, under tools then edit Printer Status Monitoring
Assuming the following:
This little hack will allow to print an image from a command and await job completion, with error management; and uses only windows preinstalled software
Further optimization could be done by keeping powershell subprocess active and only passing it scripts in the
& "path\to\print.ps1" "C:\absolute\path\to\file.png"
format, waiting for standard output to report an OK or a KO; but only if mass printing is required.不得不再次对此进行处理,只想使用
pywin32
软件包在“纯” python中添加更简单的解决方案
win32print
“文档”Having had to work on this again, just wanted to add a simpler solution in "pure" python using the
pywin32
packageuseful additional resources
win32print
"documentation"