<!-- Copyright (c) 2021 ActivePDF, Inc. --> <!-- ActivePDF Toolkit 2017 --> <!-- Example generated 01/23/21 --> <% Dim strPath, intOpenOutputFile, intOpenInputFile, StampFontName, _ StampFontSize, StampeFontText, StampLocationX, StampLocationY, _ TotalPages, CurrentPage, PageRotation, intGetBoundingBox, _ PageHeight, PageWidth, intCopyForm strPath = Server.MapPath(".") & "\" ' Instantiate Object Set oTK = Server.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 & "8rotations.pdf") If intOpenInputFile <> 0 Then ErrorHandler "OpenInputFile", intOpenInputFile End If ' Font and Text variables StampFontName = "Helvetica" StampFontSize = 12 StampeFontText = "Confidential" StampLocationX = 72 StampLocationY = 24 ' Get the page count of the input file TotalPages = oTK.NumPages("") If TotalPages < 1 Then ' Error getting page count of input file ErrorHandler "NumPages", TotalPages Else ' Loop through all pages of the input file For CurrentPage = 1 To TotalPages ' Get the current page width, height and rotation PageRotation = oTK.GetInputPageRotation(CurrentPage) intGetBoundingBox = oTK.GetBoundingBox("", CurrentPage) If intGetBoundingBox <> 0 Then ErrorHandler "GetBoundingBox", intGetBoundingBox End If PageHeight = oTK.BBHeight PageWidth = oTK.BBWidth ' Set font properties and text rotation oTK.SetFont StampFontName, StampFontSize, CurrentPage oTK.SetTextColor 255, 0, 0, 0, CurrentPage oTK.SetTextRotation PageRotation ' Depending on the rotation of the page, adjust coordinates ' This only accounts for rotations of 0, 90, 180, 270 Select Case PageRotation Case 0 oTK.PrintText StampLocationX, StampLocationY, StampeFontText, CurrentPage Case 90 oTK.PrintText PageWidth - StampLocationY, StampLocationX, StampeFontText, CurrentPage Case 180 oTK.PrintText PageWidth - StampLocationX, PageHeight - StampLocationY, StampeFontText, CurrentPage Case 270 oTK.PrintText StampLocationY, PageHeight - StampLocationX, StampeFontText, CurrentPage Case Else ErrorHandler "Page Rotation", PageRotation End Select ' Copy the current page to the output file intCopyForm = oTK.CopyForm(CurrentPage, CurrentPage) If intCopyForm <> 1 Then ErrorHandler "CopyForm", intCopyForm End If Next End If ' Close the new file to complete PDF creation oTK.CloseOutputFile ' Release Object Set oTK = Nothing ' Process Complete Response.Write "Done!" ' Error Handling Sub ErrorHandler(method, outputCode) Response.Write("Error in " & method & ": " & outputCode) End Sub %>