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

How to extract field names as text?

charlie6067
Registered: Nov 22 2006
Posts: 37

In developing a form, it's useful to extract the text field names into a document as final check for the design document. Is there a way to extract only the field names in a form? Using 8 Pro.

Thanks,
Charlie
charlie6067

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
See Field Names and Field Lengths, http://forum.planetpdf.com/wb/default.aspaction=9&read=46293&fid=5#125500 , for an example of outuptting to the JS console or a report.

George Kaiser

charlie6067
Registered: Nov 22 2006
Posts: 37
Thank you!
Charlie
charlie6067
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If the previous posted link doe not work, following is some JavaScript code that can be run from the JavaScript console or debugger to output to the console or as an individual report.

To list the field names on the JavaScript console (cut & paste for a hard copy):// Enumerate through all of the fields in the document.
for (var i = 0; i < this.numFields; i++)
console.println("Field[" + i + "] = " + this.getNthFieldName(i));


Or a PDF with the form's field information:

/* Report of form fields in a PDF file */
// declare the variables
rep = new Report(); // declare new report
rep.color = ["RGB",0,.5,0.5];
rep.writeText("PDF Document and Form Field Information Report"); // report title
rep.writeText(""); // blank line
rep.divide(); // divider line
rep.indent();
rep.color = color.red; // get some file information
rep.writeText("File Name: " + this.path);
rep.indent();
rep.color = color.black;
rep.writeText("Title: " + this.info.title);
rep.writeText("Author: " + this.info.author);
rep.writeText("Subject: " + this.info.subject);
rep.writeText("Keywords: " + this.info.keywords);
rep.writeText("Creation Date: " + this.info.creationDate);
rep.writeText("Modification Date: " + this.info.ModDate);
rep.divide();
rep.writeText("File Size: " + this.filesize);
rep.writeText("Page Count: " + this.numPages);
rep.writeText("Field Count: " + this.numFields);
rep.indent();
rep.divide();
if (this.numFields !=0){
for (i = 0; i < this.numFields; i++){
// Enumerate through all of the fields in the document.
var cFieldName = this.getNthFieldName(i); // get a field name
var cField = this.getField(cFieldName); // get field
rep.writeText(i+1 + " Field Name: " + cField.name + ", Field Type: " + cField.type);
if(cField.type == "text") rep.writeText("Character Limit: "+ cField.charLimit);
if (cField.type != "button" | cField.type != "signature") rep.writeText(" Default Value: " + cField.defaultValue);
var FieldDisplay = ''; // field display attribute
if (cField.display == display.visible) FieldDisplay = "Visible";
if (cField.display == display.hidden) FieldDisplay = "Hidden";
if (cField.display == display.noPrint) FieldDisplay = "Visible No Print";
if (cField.display == display.noView) FieldDisplay = "Print Not Visible";
if (FieldDisplay == "") FieldDisplay = "Unknown";
rep.writeText("Display attribute: " + FieldDisplay + ", Read Only Attribute: " + cField.readonly);
rep.writeText("Short Description: " + cField.userName);
rep.divide();
} // end for
} // end if numFields != 0
rep.writeText(" ");
rep.outdent();
rep.outdent();
rep.outdent();

rep.writeText("");
rep.color = ["RGB", 0, 0.5, 0.5];
rep.divide();
rep.indent();
rep.size = 1.1;
rep.writeText("Date: " + new Date()); // document date & time
rep.open("Document Info Report"); // open the completed report

The above could be written as a function and thenb added as a menu item to your Acrobat program.

George Kaiser

charlie6067
Registered: Nov 22 2006
Posts: 37
Thank you again for the help.
Charlie
charlie6067