Example code is for an older version of Toolkit, newer code is available.
' Copyright (c) 2021 ActivePDF, Inc.
' ActivePDF Toolkit 2017
' Example generated 04/17/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 strPath As String, lngLinearized As Boolean, intLinearizeFile As Integer
strPath = AppDomain.CurrentDomain.BaseDirectory
' Instantiate Object
Dim oTK As APToolkitNET.Toolkit = New APToolkitNET.Toolkit()
' Check to see if the PDF is already linearized
lngLinearized = oTK.IsFileLinearized(strPath & "PDF.pdf")
' If not, then linearize the file
If lngLinearized = false Then
intLinearizeFile = oTK.LinearizeFile(strPath & "PDF.pdf", strPath & "new.pdf", "")
If intLinearizeFile < 0 Then
ErrorHandler("LinearizeFile", intLinearizeFile)
End If
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