使用.bat和.vbs。如何从1000个PDF中的每一个打印第一页?
我发现唯一可行的解决方案是:
Option Explicit
Const FILE_TO_PRINT = "n:\xxx\xxx\xxx\xxx\xxxx.PDF"
Dim shl
Dim fldr
Dim files,file
Set shl = CreateObject("Shell.Application")
Set fldr = shl.Namespace("n:\HEAT06\BAA Cards\66712\20161103\")
Set files = fldr.Items
For Each file in files
If LCase(file.Path) = LCase(FILE_TO_PRINT) Then
file.InvokeVerbEx("Print")
End If
Next
Set shl = Nothing
Set fldr = Nothing
Set files = Nothing
WScript.Quit
它确实有效,但是当我只需要第一页时,它会打印整个文档。
答案 0 :(得分:1)
附上我几年前写的VBS,它会将您放在其上的所有文件的第一页打印到默认打印机。您可以将其更改为您需要的内容。如果你使用它与拖放&请记住,您必须拖动标记的文件从第一个或最后一个文件,以便按照标记文件的方式对打印输出进行排序。 HTH,Reinhard
'//Print first page of pdfs
set WshShell = CreateObject ("Wscript.Shell")
set fs = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
if objArgs.Count < 1 then
msgbox("Please drag a file on the script")
WScript.quit
end if
'contact Acrobat
Set gApp = CreateObject("AcroExch.App")
gApp.show 'comment or take out to work in hidden mode
'open via Avdoc and print
for i=0 to objArgs.Count - 1
FileIn = ObjArgs(i)
Set AVDoc = CreateObject("AcroExch.AVDoc")
If AVDoc.Open(FileIn, "") Then
Set PDDoc = AVDoc.GetPDDoc()
Set JSO = PDDoc.GetJSObject
jso.print false, 0, 0, true
gApp.CloseAllDocs
end if
next
gApp.hide : gApp.exit : Quit()
MsgBox "Done!"
Sub Quit
Set JSO = Nothing : Set PDDoc = Nothing : Set gApp =Nothing : Wscript.quit
End Sub