' Copyright (c) 2021 ActivePDF, Inc. ' ActivePDF Toolkit 2018 ' Example generated 03/05/21 Dim FSO, strPath, intOpenOutputFile, intOpenInputFile, _ intCopyForm, strXMLData ' Get current path Set FSO = CreateObject("Scripting.FileSystemObject") strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\" Set FSO = Nothing ' Instantiate Object Set oTK = CreateObject("APToolkit.Object") ' This example will take a PDF and add a comment to it ' then it will extract the comment from the new PDF ' 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 comment to first page of the input PDF oTK.AddComment 72.0, 660.0, 144.0, 100.0, "Lorem Ipsum", "Test", 0, 128, "#BEBEBE", true, 1, "John Doe", "Lorem" ' Copy the template (with any changes) to the new file intCopyForm = oTK.CopyForm(0, 0) If intCopyForm <> 1 Then ErrorHandler "CopyForm", intCopyForm End If ' Close the new file to complete PDF creation oTK.CloseOutputFile ' Open the PDF with a comment intOpenInputFile = oTK.OpenInputFile(strPath & "new.pdf") If intOpenInputFile <> 0 Then ErrorHandler "OpenInputFile", intOpenInputFile End If ' Extract the comments as XML Data to a variable ' Use the strXMLData variable to handle the XML data strXMLData = oTK.ExportComments(0) ' Close the PDF input file oTK.CloseInputFile ' Release Object Set oTK = Nothing ' Process Complete Wscript.Echo("Done!") ' Error Handling Sub ErrorHandler(method, outputCode) Wscript.Echo("Error in " & method & ": " & outputCode) End Sub