<!-- Copyright (c) 2019 ActivePDF, Inc. --> <!-- ActivePDF Toolkit 2018 --> <!-- Example generated 12/06/19 --> <% Dim strPath, intOpenOutputFile, intOpenInputFile, intAddPageRange, _ 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 & "10pages.pdf") If intOpenInputFile <> 0 Then ErrorHandler "OpenInputFile", intOpenInputFile End If ' Using page ranges first, before using CopyFrom will improve performance ' Once CopyFrom or MergeFile are called then the actual copy of the specified ' page ranges will occur ' Add a page rage and stamp it with the original page number oTK.SetFont "Helvetica", 12, 1 oTK.PrintText 72, 760, "Originally page 1", 1 intAddPageRange = oTK.AddPageRange(1, 1) If intAddPageRange <> 1 Then ErrorHandler "AddPageRange", intAddPageRange End If oTK.SetFont "Helvetica", 12, 3 oTK.PrintText 72, 760, "Originally page 3", 3 intAddPageRange = oTK.AddPageRange(3, 3) If intAddPageRange <> 1 Then ErrorHandler "AddPageRange", intAddPageRange End If oTK.SetFont "Helvetica", 12, 5 oTK.PrintText 72, 760, "Originally page 5", 5 intAddPageRange = oTK.AddPageRange(5, 5) If intAddPageRange <> 1 Then ErrorHandler "AddPageRange", intAddPageRange End If ' Copy the set page ranges to the new file ' CopyForm parameters will be ignored when using AddPageRange intCopyForm = oTK.CopyForm(0, 0) If intCopyForm <> 1 Then ErrorHandler "CopyForm", intCopyForm 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 %>