These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Simple text field question

JR_1011
Registered: Jan 28 2011
Posts: 3

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

My Product Information:
Acrobat Pro 7.1.4, Windows
JR_1011
Registered: Jan 28 2011
Posts: 3
This was cut-off...

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();
}
JR_1011
Registered: Jan 28 2011
Posts: 3
Well it seems all I needed to do was try to update Acrobat and reboot a couple times. I don't think the update even took because i still have version 7.1.0, when I checked for updates again it told me I needed the same update I had just installed. Oh well..

Anyway it started working after that using the JS function to addField.