2016-11-07 42 views
-2

通过使用.bat和.vbs。如何从1000个PDF中打印第一页?从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

Acrobat是否具有类似于Word.Application的界面? http://www.visualbasicscript.com/vbs-to-print-three-pages-from-ms-word-m70929.aspx – lit

+0

哪个Programm用于PDF打印? Adobe Reader? – ReFran

+0

@ReFran使用Adobe Acrobat 11 Pro – Denis

回答

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