Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Interactive PDF, Field Name and Tooltip Export Data

New Here ,
Sep 30, 2021 Sep 30, 2021

I have PDF documents that contain text fields and check box fields. I need to export all the check box names and their tooltips to a separate file. I tried a script from Acrobat console and it returns the names and tooltips, but the names are in alphabetical order and script would fail if a field was missing a tooltip. 

 

Does anyone know if there is a way to modify this script to return the field names in the same order as they're found in the document? Is there also a way to have the script ignore tooltip fields that are blank? Is there a better way to do this?

 

var Data
for(i=0;i<this.numFields;i++)
{
   var cName = this.getNthFieldName(i);
   var cToolTip = this.getField(cName).userName;
   Data += cName + "; " + cToolTip + "\n";
}
var doc = this.createDataObject({cName: "data.txt", cValue: Data});
this.exportDataObject({cName: "data.txt", nLaunch:0});

 

I appreciate any help you can provide. Thank you! 

TOPICS
How to , JavaScript , PDF forms
5.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2021 Sep 30, 2021

What do you mean by "the same order as they're found in the document"? Do you mean based on their physical location? If so, what order would that be?

 

To ignore fields without a tooltip change this line:

 

Data += cName + "; " + cToolTip + "\n";

 

To:

 

if (cToolTip!="") Data += cName + "; " + cToolTip + "\n";

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 01, 2021 Oct 01, 2021

Thank you for your help, try67! Adding if (cToolTip!="") allowed me to ignore fields without tooltips. 

 

The order I'm referring to is the sequence they're found in the document, regardless of the name or tooltip. 

 

On page 1:

[] Name: PART_X, Tooltip: Product Pie

[] Name: PART_A, Tooltip: Product Cake

On page 2:

[] Name: PART_E, Tooptip: Product Cookie

 

I would like the script result to be in the order they occur above, Product Pie, Product Cake, then Product Cookie. The script output file instead lists them alphabetical by Name, Product Cake, Product Cookie, then Product Pie. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2021 Oct 01, 2021

The script does not access them in alphabetical order, but according to the internal order, which is the order in which they were created. If you want any other order you will need to either write a sort function, or specify them in the desired order in an array, and then iterate over that array.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2023 Feb 14, 2023

Hi try67, 

I am also having the same issue while exporting the fillable fields tooltip/ field name. I am not good @ java script, can you help me with the scipt to extract the fillable fields tooltip/ field name in the same order as it appers in the document. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

What do you mean by "the same order it appears in the document", exactly?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Sorting by page number and/or the physical location on the page is not a trivial task, but you can get a pretty good result with this code:

 

var allFields = [];
for (var i=0; i<this.numFields; i++) {
	var f = this.getField(this.getNthFieldName(i));
	if (f==null) continue;
	allFields.push(f);
}
allFields.sort(sortByPageNumber);
console.clear();
console.println("Field Name;Page(s);Tooltip");
for (var i=0; i<allFields.length; i++) {
	console.println(allFields[i].name + ";" + allFields[i].page + ";" + allFields[i].userName);
}


function sortByPageNumber(a,b){
	var pageA = a.page;
	if (typeof pageA=="object") pageA = pageA[0];
	var pageB = b.page;
	if (typeof pageB=="object") pageB = pageB[0];
	return pageA-pageB;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2023 Feb 14, 2023

Thank you so much for the response Try67, However as i mentioned not good at the Java script. 

Below is the Script I used to export the filed information. 

 

var ySummary
for(i=0;i<this.numFields;i++)
{
var zName = this.getNthFieldName(i);
var aToolTip = this.getField(zName).userName;
ySummary += zName + " : " + aToolTip + "\n";
}


var fileName = this.documentFileName.replace(/\.[^.]+$/, '');
this.createDataObject(fileName+".xls", ySummary); this.exportDataObject(fileName+".xls");

 

Can you please let me know where should i modify the Script

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Just use my code and then copy the output from the Console into Excel. In order for it to work directly replace all instances of ";" with "\t", though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 14, 2023 Feb 14, 2023

Thank a lot Try67 It works fine!!! however unable to export as excel format. I am able to copy from the console.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

If you want to export it use a text file. If it's tab-delimited you would be able to open it directly in Excel.

Creating a real .xls(x) file is not possible.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 17, 2023 Feb 17, 2023

Hi Try 67, 

Is there is any way to extract the formating of the form field in a pdf document using Javascript. 

Example : Date: format mm/dd/yyyy, Social security number format, Phone number format.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2023 Feb 17, 2023

No.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 17, 2023 Feb 17, 2023
LATEST

Thank you  Try67, 

Let me check for workaround.

 

Mab

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2023 Feb 17, 2023

@robertw19850899  and @Magendravarad28403894r8lu ,

 

Would it work for you to do this?

  • Form editing tool
  • Select fields
  • Copy
  • Open other document > go to Form editing > Paste

It doesn't use JavaScript, but it does put the fields with their properties in another document.

 

Jane

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 17, 2023 Feb 17, 2023

Hi Jane, 

Thanks you for the response, However I have validate the format for the fields for 100 of files from customer. so if I have option to export the form field properties it will help me to identifie the issues. 

Example: Date, Phone number etc. And I am not creating the forms I just make it accessible with the tags.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines