I'm very familiar with JavaScript and less familiar with Acrobat. I've successfully written a script that runs in Batch Processing. It gets values from my database based on the name of the current batch file, and from there, I need the result to populate a text field in a temp PDF and merged into the current document.
I've tried populating the value using an already created text field in Designer as well as dynamically adding a field in JS, but I can't seem to get the field populated. Hopefully I just overlooked something simple and someone can help me out. Thanks. Here's what I have tried so far.
var docTitle = this.documentFileName;
var dbConn = null;
try
{
dbConn = ADBC.newConnection("pds");
var stmtObj = dbConn.newStatement();
var sqlToExecute = "SELECT pd FROM journal_pages WHERE pd = '"+docTitle.substring(0,docTitle.indexOf("."))+"'";
stmtObj.execute(sqlToExecute);
if(stmtObj.rowCount > 0)
{
var tocDoc = app.openDoc({cPath: "/c/docroot/pds/cToc.pdf"});
//console.println("\nValue: " + tocDoc.getField("F[0].P1[0].PD[0]").rect);
//399.5719909667969,698.427978515625,513.8920288085938,678.5859985351562
for(var i=0; i
stmtObj.nextRow();
var row = stmtObj.getRow();
if(i==0)
{
/*
var f = function(tocDoc){tocDoc.addField({cName: "PD",
cFieldType: "text",
oCoords: [399.5719909667969,698.427978515625,513.8920288085938,678.5859985351562],
nPageNum: "0"
});
};
f.value = row.pd.value;
*/
tocDoc.xfa.form.F.P1.PD.rawValue = row.pd.value;
//console.println('\n'+row.pd.value);
break;
}}tocDoc.saveAs({cPath: "/c/docroot/pds/tmp_toc.pdf"});
tocDoc.closeDoc(true);
this.insertPages({nPage: -1, cPath: "/c/docroot/pds/tmp_toc.pdf", nStart: 0});
}}
catch(exc)
{
console.println(exc);
throw "Exception Thrown!!";
}
finally
{
dbConn.close();
}