<!-- Copyright (c) 2021 ActivePDF, Inc. --> <!-- ActivePDF Toolkit 2018 --> <!-- Example generated 01/23/21 --> <!-- 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); } // Specify the template form to populate oTK.SetDBInputTemplate(strPath & "dbtemplate.pdf"); // Set query command to a variable strSQL = "Select * From Supplier"; // Set connection String to a variable strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "xtreme.mdb" & ";Persist Security Info=False"; // Set master query oTK.SetMasterQuery(strConn, "Admin", "", -1, strSQL); // Set the row Separator oTK.SetDBMultiRowSeparator(""); // Related query separator is only needed if different from default of '|' oTK.Set_RelatedQuerySeparator("|"); // Add related query oTK.AddRelatedQuery(strConn, "Admin", "", -1, strSQL, true); // If db column names are different then field names a map file is needed // In this example only the zip/postal code is different intLoadDBMapFile = oTK.LoadDBMapFile(strPath & "dbformmap.txt"); if(intLoadDBMapFile != 0) { Error("LoadDBMapFile", intLoadDBMapFile); } // Flatten fields that are populated with data oTK.SetDefaultDBMergeFlag(-997); // Flatten all other fields on the form oTK.Set_FlattenRemainingFormFields(1); // Fill the template form intDBToForm = oTK.DBToForm(false); if(intDBToForm != 0) { Error("DBToForm", intDBToForm); } // Clear and close used queries oTK.ClearQueries(); // Close the output file oTK.CloseOutputFile(); // Release Object oTK = 0; // Process Complete WriteOutput("Done!"); // Error Handling Function Error(method, outputCode) { WriteOutput("Error in " & method & ": " & outputCode); } </CFSCRIPT>