I have a text file attached to my PDF. Each line in the text file should be an unique value within the combobox. I am adding a "OnFocus -> Run Javascript" command to the text box. I am then using the following code:
var oFile = this.getDataObjectContents("doctypes.txt");
var cFile = util.stringFromStream(oFile, "utf-8");
this.getField("txtDocTypeText").clearItems;
var cLines = cFile.split("\r\n");
for (i=0; i Parameter cName.
-----------------------------
Thanks.
The following script works for me in version 7:
console.show(); console.clear();
console.println("\nCreate data object:");
// create data object
this.createDataObject("doctypes.txt", "TXT\r\nDAT\r\nDOC\r\nDOCX", "utf-8");
// list data objects
console.println("\nList of data objects:");
var d = this.dataObjects;
for (var i = 0; i < d.length; i++)
console.println("Data Object[" + i + "]=" + d[i].name);
// list data object properties
console.println("\nProperites for data object:");
var MyData = this.getDataObject("doctypes.txt");
for (var i in MyData) console.println("DocTypes." + i + "=" + MyData[i]);
// list contents
console.println("\nContents of data object:");
if ( app.viewerVersion >= 7 ) {
// get the file stream object of the embedded file
var oFile = this.getDataObjectContents("doctypes.txt");
// convert to a string & print
var sContents = util.stringFromStream(oFile, "utf-8");
console.println("Lenght of contents: " + sContents.length);
console.println(sContents);
} else {
app.alert("Acrobat 7.0 or later is required.");
}
console.println("\nArray element contents");
var aContents = sContents.split("\r\n");
console.println("Number of arrays: " + aContents.length);
for (i = 0; i < aContents.length; i++)
console.println(i + ": " + aContents[i]);
var oFile = this.getDataObjectContents("doctypes.txt");
var cFile = util.stringFromStream(oFile, "utf-8");
this.getField("txtDocTypeText").clearItems();
var cLines = cFile.split("\r\n");
for (i=0; i
George Kaiser