' Copyright (c) 2021 ActivePDF, Inc. ' ActivePDF Toolkit 2017 ' Example generated 03/03/21 Imports System ' Make sure to add the ActivePDF product .NET DLL(s) to your application. ' .NET DLL(s) are typically found in the products 'bin' folder. Public Class Examples Sub Example() Dim certID As Integer, CreateCertResult As Integer, strPath As String, intVisiblySignFile As Integer strPath = AppDomain.CurrentDomain.BaseDirectory ' Instantiate Object Dim oTK As APToolkitNET.Toolkit = New APToolkitNET.Toolkit() ' Find certificate, if it doesn't exist it will be created ' If you have an existing signature you can find it with FindCertificate ' and remove the portion of code that creates the certificate certID = oTK.FindCertificate("John Doe", "My", 0) If certID < 1 Then ' Certificate not found, create a certificate with Toolkit CreateCertResult = oTK.CreateCertificate("John Doe", "Management", "Doe Enterprises", "Mission Viejo", "CA", "US", "john@doee.com", 0, "My", 365, 0, "", "") If CreateCertResult = 1 Then ' New certificate created, find it for use certID = oTK.FindCertificate("John Doe", "My", 0) If certID < 1 Then ErrorHandler("FindCertificate", certID) End If Else ' Create certificate failed ErrorHandler("CreateCertificate", CreateCertResult) End If End If ' Visibly sign an existing PDF intVisiblySignFile = oTK.VisiblySignFile(certID, strPath & "PDF.pdf", strPath & "new.pdf", "Mission Viejo, CA", "Security", "949-555-1212", "", 8, "Signed Document", "Helvetica", 12, 416.0, 730.0, 124.0, 40.0, 1, 1) If intVisiblySignFile <> 0 Then ErrorHandler("VisiblySignFile", intVisiblySignFile) End If ' Release Object oTK.Dispose() ' Process Complete WriteResults("Done!") End Sub ' Error Handling ' Error messages written to debug output Sub ErrorHandler(ByVal strMethod, ByVal RtnCode) WriteResults(strMethod + " error: " + rtnCode.ToString()) End Sub ' Write output data Sub WriteResults(content As String) ' Choose where to write out results ' Debug output 'System.Diagnostics.Debug.WriteLine("ActivePDF: * " + content) ' Console Console.WriteLine(content) ' Log file 'Using tw = New System.IO.StreamWriter(AppDomain.CurrentDomain.BaseDirectory & "application.log", True) ' tw.WriteLine("[" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "]: => " + content) 'End Using End Sub End Class