Example code is for an older version of Toolkit, newer code is available.
<?php
// Copyright (c) 2021 ActivePDF, Inc.
// ActivePDF Toolkit 2016
// Example generated 03/05/21
?>
<?php
// Get current path
$strPath = dirname(__FILE__) . "\\";
// Instantiate Object
$oTK = new COM("APToolkit.Object");
// 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->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->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 = null;
// Process Complete
echo "Done!";
// Error Handling
function Error($method, $outputCode) {
echo "Error in " . $method . ": " . $outputCode;
}
?>