I have been given a PDF file with a form. The form is not formatted as a table. My requirement is to extract the form field values, and write them to a CSV file which can be imported into Excel. I have tried using the automated "Merge data files to Spreadsheet" menu item in Acrobat Pro, but the output includes both the labels and form field values. I am interested in mostly just the form field values.
I would like to use JavaScript to extract the form data, and instruct JavaScript how to write the CSV (since I know what the end spreadsheet should look like). I got as far as extracting the form fields:
this.getField("Today_s_Date").value;
And following this post: How to write a text file in Acrobat Javascript , I tried to write to CSV using:
var cMyC = "abc";
var doc = this.createDataObject({cName: "test.txt", cValue: cMyC});
but I get the following error:
"SyntaxError: syntax error 1:Console:Exec"
Ideally, I do not want to use an online third party tool to do this, because the data is sensitive. But please let me know if you have suggestions. The ideal output will be a CSV file that an end business user can open in Excel to see the spreadsheet format of her choice.
Has anyone done this before? Open to hearing any alternative solutions as well. Thanks in advance!