<!-- Copyright (c) 2019 ActivePDF, Inc. --> <!-- ActivePDF Toolkit 2017 --> <!-- Example generated 12/12/19 --> <!-- Example uses the .NET DLL which requires --> <!-- Coldfusion 8 or above --> <CFSCRIPT> // Get current path strPath = ExpandPath(".") & "\"; // Instantiate Object oTK = CreateObject(".NET", "APToolkitNET.Toolkit", "C:\Program Files\activePDF\Toolkit\DotNetComponent\2.0\APToolkitNET.dll"); // Create the new PDF file intOpenOutputFile = oTK.OpenOutputFile(strPath & "new.pdf"); if(intOpenOutputFile != 0) { Error("OpenOutputFile", intOpenOutputFile); } // Open the template PDF intOpenInputFile = oTK.OpenInputFile(strPath & "PDF.pdf"); if(intOpenInputFile != 0) { Error("OpenInputFile", intOpenInputFile); } // Add a 'Confidential' watermark by setting text transparency // Rotation and color of the text along with the fill mode are set // -1 is used for the optional page number parameter to stamp on all pages oTK.SetFont("Helvetica", 90, -1); oTK.SetTextTransparency(0.6, 0.6); oTK.SetTextRotation(45); oTK.SetTextStrokeColor(255, 0, 0, 0, -1); oTK.SetTextFillMode(1); oTK.PrintText(154, 184, "Confidential", -1); oTK.ResetTextTransparency(); oTK.SetTextFillMode(0); // Add a 'Top Secret' watermark oTK.SetFont("Helvetica", 72, -1); oTK.SetTextColor(200, 200, 200, 0, -1); oTK.PrintText(154, 300, "Top Secret", -1); oTK.ResetTextColor(-1); oTK.SetTextRotation(0); // Add the document title to the bottom center of the page oTK.SetFont("Helvetica", 12, -1); strTitle = "Lorem Ipsum"; textWidth = oTK.GetTextWidth(strTitle); oTK.PrintText((612 - textWidth) / 2, 32, strTitle, -1); // Add a mulitline print box for an 'approved' message in header // 1 is used for the optional page number parameter to stamp only on the first page oTK.SetTextFillMode(2); oTK.SetTextColorCMYK(0, 0, 0, 20, 1); oTK.SetTextStrokeColorCMYK(0, 0, 0, 80, 1); oTK.PrintMultilineText("Helvetica", 22, 344, 766, 190, 86, "Approved on January 17th, 2021", 2, 1); oTK.ForceColorReset(-1); // Use the Print Image properties to add some images to the footer oTK.Set_ImageRotation(0); oTK.PrintImage(strPath & "BMP.bmp", 375.0, 13.0, 0.0, 0.0, true, -1); oTK.PrintJPEG(strPath & "JPEG.jpg", 436.0, 9.0, 0.0, 0.0, true, -1); oTK.PrintTIFF(strPath & "TIFF.tif", 500.0, 15.0, 0.0, 0.0, true, -1); // Add a gray line to separate the content from the footer oTK.GreyBar(72.0, 52.0, 468.0, 1.0, 0.8, -1); // Copy the template (with the stamping changes) to the new file // Start page and end page, 0 = all pages intCopyForm = oTK.CopyForm(0, 0); if(intCopyForm != 1) { Error("CopyForm", intCopyForm); } // Close the new file to complete PDF creation oTK.CloseOutputFile(); // Release Object oTK = 0; // Process Complete WriteOutput("Done!"); // Error Handling Function Error(method, outputCode) { WriteOutput("Error in " & method & ": " & outputCode); } </CFSCRIPT>