' AddWatermarkToPDF script ' Part of PDFCreator ' License: GPL ' Homepage: http://www.sf.net/projects/pdfcreator ' Version: 1.1.0.0 ' Date: September, 1. 2005 ' Author: Frank Heindörfer ' Comments: This script needs pdftk. ' For more informations about the freeware pdftk use this link: ' http://www.accesspdf.com Option Explicit Const AppTitle = "PDFCreator - AddWatermarkToPDF" Const PathToPdftk = "c:\pdftk\bin\pdftk.exe" Const WatermarkPDF = "c:\pdftk\watermark.pdf" Const Language = "de" ' Sprachenkürzel nach ISO 639-1 ' Dim objArgs, fname, tfname, fso, WshShell, oExec Set objArgs = WScript.Arguments If objArgs.Count = 0 Then Select Case Language Case "en" MsgBox "This script needs a parameter!", vbExclamation, AppTitle Case "de" MsgBox "Dieses Script benötigt einen Parameter!", vbExclamation, AppTitle Case Else MsgBox "Please set the language", vbExclamation, AppTitle End Select WScript.Quit End If fname = objArgs(0) Set fso = CreateObject("Scripting.FileSystemObject") If Ucase(fso.GetExtensionName(fname)) <> "PDF" Then MsgBox "This script works only with pdf files!", vbExclamation, AppTitle Select Case Language Case "en" MsgBox "This script works only with pdf files!", vbExclamation, AppTitle Case "de" MsgBox "Das Script arbeite nur mit PDF-Dateien!", vbExclamation, AppTitle Case Else MsgBox "Please set the language", vbExclamation, AppTitle End Select WScript.Quit End If If Not fso.FileExists(PathToPdftk) Then Select Case Language Case "en" MsgBox "You need pdftk for this script!" & vbcrlf & vbcrlf & _ "Please go to http://www.accesspdf.com and download it.", vbExclamation, AppTitle Case "de" MsgBox "Sie benötigen pdftk zur Ausführung des Script!" & vbcrlf & vbcrlf & _ "Bitte von der Webseite http://www.accesspdf.com herunterladen", vbExclamation, AppTitle Case Else MsgBox "Please set the language", vbExclamation, AppTitle End Select WScript.Quit End If If Not fso.FileExists(WatermarkPDF) Then Select Case Language Case "en" MsgBox "Can't find the watermark pdf file!", vbExclamation, AppTitle Case "de" MsgBox "Die Wasserzeichen PDF-Datei wurde nicht gefunden!", vbExclamation, AppTitle Case Else MsgBox "Please set the language", vbExclamation, AppTitle End Select WScript.Quit End If Set WshShell = CreateObject("WScript.Shell") tfname = "C:\pdftk\temp\output.tmp" ' Anzeiche/Prüfung der Übergabeparameter 'MsgBox """" & PathToPdftk & """ """ & fname & """ background """ & WatermarkPDF & """ output """ & tfname & """", vbExclamation, AppTitle WshShell.Run """" & PathToPdftk & """ """ & fname & """ background """ & WatermarkPDF & """ output """ & tfname & """",0,true If Not fso.FileExists(tfname) Then Select Case Language Case "en" MsgBox "There was an error using ""pdftk""!", vbCritical, AppTitle Case "de" MsgBox "Beim Einsatz von ""pdftk"" ist ein Fehler aufgetreten!" & vbcrlf & vbcrlf & _ "Bitte prüfen Sie ob Umlaute im Verzeichnis oder Dateinnamen verwendet wurden !!", vbCritical, AppTitle Case Else MsgBox "Please set the language", vbExclamation, AppTitle End Select WScript.Quit End If If fso.FileExists(fname) Then fso.DeleteFile(fname) End If fso.MoveFile tfname, fname