Example code is for an older version of Toolkit, newer code is available.
' Copyright (c) 2021 ActivePDF, Inc.
' ActivePDF Toolkit 2017
' Example generated 01/25/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, intNumPages As Integer, pageRotation As Integer, pageWidth As Integer, _
pageHeight As Integer, pageLeft As Integer, pageTop As Integer
strPath = AppDomain.CurrentDomain.BaseDirectory
' Instantiate Object
Dim oTK As APToolkitNET.Toolkit = New APToolkitNET.Toolkit()
' Get the page count of the PDF
intNumPages = oTK.NumPages(strPath & "PDF.pdf")
If intNumPages < 1 Then
ErrorHandler("NumPages", intNumPages)
End If
' Get the rotation of the page
' Note: there is no need to open an input file as NumPages opened the PDF
pageRotation = oTK.GetInputPageRotation(1)
' Close the input file
oTK.CloseInputFile()
' Load the page 1 details of the PDF
oTK.GetBoundingBox(strPath & "PDF.pdf", 1)
' Get the Page Width and Height
pageWidth = oTK.BoundingBoxWidth
pageHeight = oTK.BoundingBoxHeight
' Get the left and top coordinates of the bounding box
pageLeft = oTK.BoundingBoxLeft
pageTop = oTK.BoundingBoxTop
' With the data set to variables they can be used where needed
' Close the input file as it's no longer needed
oTK.CloseInputFile()
' 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