' Copyright (c) 2021 ActivePDF, Inc. ' ActivePDF Toolkit 2017 ' Example generated 04/10/21 Dim FSO, strPath, intOpenOutputFile, intOpenInputFile, _ strTitle, textWidth, intCopyForm ' Get current path Set FSO = CreateObject("Scripting.FileSystemObject") strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\" Set FSO = Nothing ' Instantiate Object Set oTK = CreateObject("APToolkit.Object") ' Create the new PDF file intOpenOutputFile = oTK.OpenOutputFile(strPath & "new.pdf") If intOpenOutputFile <> 0 Then ErrorHandler "OpenOutputFile", intOpenOutputFile End If ' Open the template PDF intOpenInputFile = oTK.OpenInputFile(strPath & "PDF.pdf") If intOpenInputFile <> 0 Then ErrorHandler "OpenInputFile", intOpenInputFile End If ' Add a 'Confidential' watermark by setting text transparency ' Rotation and color of the text along with the fill mode are set oTK.SetHeaderFont "Helvetica", 90 oTK.SetHeaderTextTransparency 0.6, 0.6 oTK.SetHeaderRotation 45 oTK.SetHeaderTextStrokeColor 255, 0, 0, 0 oTK.SetHeaderTextFillMode 1 oTK.SetHeaderText 154, 184, "Confidential" oTK.ResetHeaderTextTransparency oTK.SetHeaderTextFillMode 0 ' Add a 'Top Secret' watermark by placing text in the foreground oTK.SetHeaderFont "Helvetica", 72 oTK.SetHeaderTextBackground 1 oTK.SetHeaderTextColor 200, 200, 200, 0 oTK.SetHeaderText 154, 300, "Top Secret" oTK.ResetHeaderTextColor oTK.SetHeaderRotation 0 ' Add the document title to the bottom center of the page oTK.SetHeaderFont "Helvetica", 12 strTitle = "Lorem Ipsum" textWidth = oTK.GetHeaderTextWidth(strTitle) oTK.SetHeaderText (612 - textWidth) / 2, 32, strTitle ' Add page numbers to the bottom left of the page oTK.SetHeaderFont "Helvetica", 12 oTK.SetHeaderWPgNbr 72, 32, "Page %p", 1 ' Add a mulitline print box for an 'approved' message in header oTK.SetHeaderTextFillMode 2 oTK.SetHeaderTextColorCMYK 0, 0, 0, 20 oTK.SetHeaderTextStrokeColorCMYK 0, 0, 0, 80 oTK.SetHeaderMultilineText "Helvetica", 22, 344, 766, 190, 86, "Approved on January 17th, 2021", 2 oTK.ForceHeaderColorReset ' Add some lines to the footer and top right corner of the page oTK.SetHeaderGreyBar 72, 52, 468, 1, 0.8 oTK.SetHeaderHLine 340, 544, 724, 1 oTK.SetHeaderVLine 724, 648, 544, 1 ' Use the Header Image properties to add some images to the footer oTK.SetHeaderImage strPath & "BMP.bmp", 375.0, 13.0, 0.0, 0.0, true oTK.SetHeaderJPEG strPath & "JPEG.jpg", 436.0, 9.0, 0.0, 0.0, true oTK.SetHeaderTIFF strPath & "TIFF.tif", 500.0, 15.0, 0.0, 0.0, true ' Copy the template (with the stamping changes) to the new file ' Start page and end page, 0 = all pages intCopyForm = oTK.CopyForm(0, 0) If intCopyForm <> 1 Then ErrorHandler "CopyForm", intCopyForm End If ' Close the new file to complete PDF creation oTK.CloseOutputFile ' Release Object Set oTK = Nothing ' Process Complete Wscript.Echo("Done!") ' Error Handling Sub ErrorHandler(method, outputCode) Wscript.Echo("Error in " & method & ": " & outputCode) End Sub