windows 打印图片的命令行工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2301101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
command line tool for print picture?
提问by linjunhalida
My program need to print a curve, my solution is changing the curve into a picture, and this picture file (xxx.png) can be printed by using the default windows picture printing tool(right click the mouse on top of the file, and select print).
我的程序需要打印一条曲线,我的解决办法是把曲线变成图片,这个图片文件(xxx.png)可以用windows默认的图片打印工具打印出来(在文件顶部右击鼠标,然后选择打印)。
but I don't want user do this job manually, I need a command line tool to do this:
但我不希望用户手动完成这项工作,我需要一个命令行工具来做到这一点:
printPicture xxx.png
is there a tool like this?
有这样的工具吗?
ps: free/open source
ps:免费/开源
edit: right click the file, and select "print", then I can print this file, How can I do it in command line ?
编辑:右键单击该文件,然后选择“打印”,然后我可以打印此文件,我该如何在命令行中进行打印?
回答by linjunhalida
I finally found out!
我终于知道了!
use windows image and fax viewer.
使用 windows 图像和传真查看器。
rundll32 shimgvw.dll ImageView_PrintTo /pt xxx.png "printer name"
回答by Charlie Salts
IrfanViewis able to do this. Here's a list of command line optionsfor this application.
IrfanView能够做到这一点。这是此应用程序的命令行选项列表。
The following shouldwork:
以下应该工作:
i_view32 xxx.png /print
If you want to print to a printer otherthan the default printer, specify the printer name:
如果要打印到打印机其他比默认的打印机,指定打印机名称:
i_view32 xxx.png /print="PrinterName"
回答by loop
rundll32 C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo "c:\mydir\my.bmp" "Fictional HP Printer"
回答by Rodney
rundll32 C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo "c:\mydir\my.bmp" "Fictional HP Printer"
This prints an image file (.png in my case) to a specified printer WITHOUT a dialog box popping up. Also... works without elevated command prompt privileges.
这会将图像文件(在我的情况下为 .png)打印到指定的打印机,而不会弹出对话框。另外...无需提升的命令提示符权限即可工作。
回答by Harry Glinos
I had a similar problem but I also needed way to control scaling (needed for barcode work) and always have the image centered.
我有一个类似的问题,但我还需要控制缩放的方法(条形码工作所需)并始终将图像居中。
I wrote an Open Source tool called ImagePrintto do just what you want. It's written in VB.Net as a console app. At the moment, it only prints to the default printer.
我写了一个名为ImagePrint 的开源工具来做你想做的事。它是用 VB.Net 作为控制台应用程序编写的。目前,它仅打印到默认打印机。
回答by Carlos Gutiérrez
You can call ShellExecutefrom your program with print
operation:
您可以通过以下操作从您的程序中调用ShellExecuteprint
:
ShellExecute(NULL,"print","c:\test.png",NULL,NULL,SW_HIDE);