windows 从命令行以编程方式打印多个副本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3462388/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:01:28  来源:igfitidea点击:

Programmatically print multiple copies from command line

windowsbatch-filepdfprintingcmd

提问by Raj More

My application generates between 35 and 55 PDF files of which I have to automatically print four copies.

我的应用程序生成 35 到 55 个 PDF 文件,我必须自动打印四份。

All these files are in a single folder.

所有这些文件都在一个文件夹中。

My requirement is to use a batch file to print four copies of each file.

我的要求是使用批处理文件打印每个文件的四份副本。

I have Adobe Acrobat Reader installed.

我安装了 Adob​​e Acrobat Reader。

How do I do this?

我该怎么做呢?

回答by Joey

Adobe Reader is only capable of printing a single copy directly. However, nothing prevents you from looping and printing it 4 times. It may take longer, though, since the document has to be sent to the printer four times.

Adobe Reader 只能直接打印一份。但是,没有什么可以阻止您循环打印它 4 次。但是,可能需要更长的时间,因为必须将文档发送到打印机四次。

From the Acrobat SDK Developer FAQ:

来自Acrobat SDK 开发人员常见问题解答

AcroRd32.exe /t path "printername" "drivername" "portname"— Start Adobe Reader and print a file while suppressing the Print dialog box. The path must be fully specified.

The four parameters of the /toption evaluate to path, printername, drivername, and portname(all strings).

printername— The name of your printer.
drivername— Your printer driver's name, as it appears in your printer's properties.
portname— The printer's port. portnamecannot contain any "/" characters; if it does, output is routed to the default port for that printer.

AcroRd32.exe /t path "printername" "drivername" "portname"— 启动 Adob​​e Reader 并在取消打印对话框的同时打印文件。必须完全指定路径。

在四个参数/t选项评估为pathprinternamedrivername,和portname(所有字符串)。

printername— 您的打印机名称。
drivername— 您的打印机驱动程序的名称,它出现在您的打印机属性中。
portname— 打印机的端口。portname不能包含任何“/”字符;如果是,输出将路由到该打印机的默认端口。

So you can probably use something like this:

所以你可能可以使用这样的东西:

for %%F in (*.pdf) do (
  for /L %%i in (1,1,4) do (
    AcroRd32.exe /t "%%~fF" "printername" "drivername" "portname"
  )
)

Just insert the appropriate values for the missing arguments.

只需为缺失的参数插入适当的值。

回答by parth

You can use pdfprint.exe (third party utility) to achieve the purpose. We are using the same to print bunch of pdf files generated at specified location. You can write batch file whcih accepts parameter like printer name,no of copies,pdf file FULL PATH,log file name to read status,and orientation L-landscape or portrait and call batch file from some appliction like .net.

您可以使用 pdfprint.exe(第三方实用程序)来达到目的。我们使用相同的方法打印在指定位置生成的一堆 pdf 文件。您可以编写批处理文件,该文件接受打印机名称、副本数量、pdf 文件完整路径、读取状态的日志文件名、方向 L-横向或纵向等参数,并从 .net 等应用程序调用批处理文件。

We have batch file written as below:

我们有如下编写的批处理文件:

@echo off
:. %1 - Printer Name
:. %2 - Number of Copies
:. %3 - PDF File path to print
:. %4 - Name of Log file
:. %5 - Orientation of pdf printing file 1 = Portratit and 2 = Landscape
:. Add -restoreprinter -checkjobstatus which will maintain the default printer settings.

set PdfPrintPath=some valid path (C:\Folder) where pdfprint.exe is placed

%PdfPrintPath%\pdfprint.exe -restoreprinter -printer %1 -copies %2 -orient %5 %3

set ErrLevel=%errorlevel%

Please let me know for any problem. Have a nice day.

请让我知道任何问题。祝你今天过得愉快。