6 Replies Latest reply on Nov 26, 2015 7:49 PM by jalbertbowdenii

    Extract PDF Form Data Using JavaScript and write to CSV File

    darshanp42120605

      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 the values.  I am mostly just interested in 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: http://stackoverflow.com/questions/17422514/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!