No announcement yet.

JavaScript - this.importTextData not working

  • Time
  • Show
Clear All
new posts

  • JavaScript - this.importTextData not working


    I recently started using Foxit PhantomPDF (Standard Edition, ver. and I am trying to use the JavaScript console to import form field data from a tab delimited text file. I created two fields on my PDF, named Field1 and Field2, and I am attempting to run the following code:

    var myvar = this.importTextData("/c/Users/sbarry/Desktop/abc123.txt", 0)

    When I run this through the JavaScript Console, it returns "undefined". According to the documentation I have seen, the importTextData method should have a return code ranging from -3 to 3. I have also tried running this function with no arguments, which is supposed to bring up a file selection dialog, but I am also unable to make that work. The console simply says "It runs successfully".

    I made sure that "Enable JavaScript Actions" is checked under the Trust Manager tab of Preferences, and I even added C:\Users\sbarry\Desktop as a privileged location under Security.

    I am very new to javascript so I don't know if perhaps I am missing some kind of library files or something, or maybe these commands just aren't built-in to Foxit? Any help would be greatly appreciated.


  • #2

    Could you please kindly provide us the mentioned PDF document? If possible, please make a small video that shows how to replicate the problem then email to [email protected]. What's the result if you run the code in Adobe Acrobat? Thank you.


    • #3

      I just chose an arbitrary PDF file and put two form fields on it. I am attaching the .PDF, the .txt file, and a screenshot of the JavaScript console. Unfortunately, I do not have access to Adobe Acrobat to test this on.
      Attached Files


      • #4
        I just wanted to post a quick update.

        I have been playing around with this for much of the day, and I found that this.importAnFDF seems to work (as well as this.exportAsFDF). However, I still cannot get this.importTextData or this.exportAsText to work.

        I feel like there has to be a way to do this, since I am able to use the "import" and "export" buttons (on the Form tab) to interact with .txt files (although they can only have a single entry per field). I don't know if it has something to do with my installation, or maybe these JavaScript methods just aren't supported by Foxit. It's just weird, because they seem to show up as predictive text options in the Console.
        Attached Files


        • #5

          Currently Foxit PhantomPDF could recognize this function but this function can not be implemented. I've forwarded your comments as suggestion to our PM team so we could add this request to PRD. Suggestion ID#: PHANTOM-5480. Thank you.


          • #6

            The "Javascript- this.importTextData not working" has already been supported in version 9.5.0. You may give it a check at your convenience. Thank you.