2017-11-19 12 views
-2

私は膨大な数のPDF文書を持っており、すべてのページの透かしを手動でチェックしています。スクリプトを使用してこれを自動化することは可能ですか?各ページには1つのウォーターマークが含まれています。すべてのページに透かしを入れていないファイル名や文書のリストを返す方が良いでしょう。複数のPDF文書のすべてのページで透かしをチェックするスクリプト

答えて

0

pdfのウォーターマークはOCGオブジェクトに格納されます。したがって、このオブジェクトがpdfに入っていて、ウォーターマークを保持しているかどうかをacrobatに尋ねる必要があります。

これを行うことができるVBS/VBAコードを添付してください。コードをメモ帳にコピーし、デスクトップに "FindWatermarks.vbs"として保存することができます。ドラッグして&をいくつかドロップして、pdfにウォーターマークが含まれているかどうかを確認します。 Reinhard

PS:このスクリプトはAdobe Acrobat $$$バージョンでのみ動作し、Readerでは動作しません!

'// test dropped files for included watermarks 
set WshShell = CreateObject ("Wscript.Shell") 
set fs = CreateObject("Scripting.FileSystemObject") 
Set objArgs = WScript.Arguments 
    '// check if files has been dropped on the script 
if objArgs.Count < 1 then 
     msgbox("Please drag a file on the script") 
     WScript.quit 
    else 
     msgbox("Files Count: "& objArgs.Count &vblf &"Start with file: " & ObjArgs(0)) 
end if 
    '//contact Acrobat 
Set App = CreateObject("AcroExch.App") 
App.show 'comment or take out to work in hidden mode 
Set AVDoc = CreateObject("AcroExch.AVDoc") 
Set AForm = CreateObject("AFormAut.App") 'from AFormAPI 
    '// write needed js code into vbs variable 
js = "var found "&vblf _ 
    & "var ocgArray = this.getOCGs();" &vblf _ 
    & "if (ocgArray == null) {  " &vblf _ 
    & " found = 0;     " &vblf _ 
    & " }else{      " &vblf _ 
    & " for (var i=0; i < ocgArray.length; i++) { " &vblf _ 
    & "  if (ocgArray[i].name == 'Watermark') { " &vblf _ 
    & "   found= 1;   " &vblf _ 
    & "  }else{     " &vblf _ 
    & "   found = 0;   " &vblf _ 
    & "  }      " &vblf _ 
    & " }       " &vblf _ 
    & " }" 

filesWithWm = "" 
filesExWm ="" 
    '//open files via Avdoc and check for watermarks 
for i=0 to objArgs.Count - 1 
    FileIn = ObjArgs(i) 
    If AVDoc.Open(FileIn, "") Then 
     'msgbox(FileIn) 
     Set PDDoc = AVDoc.GetPDDoc() 
     Set jso = PDDoc.GetJSObject 
     AForm.Fields.ExecuteThisJavaScript js 
     if jso.found = 1 then 
      filesWithWm = filesWithWm &FileIn &vblf 
     else 
      filesExWm = filesExWm &FileIn &vblf 
     end if 

    end if 
next 
    '// report found files 
if InStr(filesWithWm,":\")>0 then msgbox("Watermarks found:" &vblf & filesWithWm) 
if InStr(filesExWm,":\")>0 then msgbox("No Watermarks found:" &vblf & filesExWm) 
    '// exit application 
App.CloseAllDocs 
App.Exit 

Set AForm = Nothing 
Set JSO = Nothing 
Set PDDoc = Nothing 
Set AVDoc = Nothing 
Set App = Nothing 

小さなコードの変更が必要な場合は教えてください。

関連する問題