Announcement

Collapse
No announcement yet.

Automatic file name in form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Feature Automatic file name in form

    Good day

    Is it possible to get Foxit to take the filename and fill it in automatic in the form?



  • #2
    Hi

    Sure, you can use this script:

    Code:
    this.getField("NAME").value = this.documentFileName;

    Comment


    • #3
      JRB where do I put this code in?

      Comment


      • #4
        hEINSTEIN ,The following Javascript codes are written into "Document Javascript" level´╝Ü
        function getname()

        {

        var f = this.getField("Text Field0");

        f.value = this.documentFileName;

        }

        getname();

        For details,please refer to attached screenshot:document javascript.jpg.
        Click image for larger version

Name:	document javascript.jpg
Views:	142
Size:	84.9 KB
ID:	179803

        Comment


        • #5
          Lisa_lee Thanx a million

          Comment


          • #6
            Lisa_lee Could you perhaps help me with getting rid of the file extension as well?
            The file names are not all the same lengths.

            Thank you
            I don't know coding (but see that I could benefit from learning it).

            Comment


            • #7
              Do you mean you want to remove '.pdf'? I am afraid it is not easier to remove it, we need to double check with my team. May I know why did you want to remove it? Thank you.

              Comment


              • #8
                Hi @Richell_huang because its my document name and we don't show the file extension in a document name.

                Comment


                • #9
                  hEINSTEIN ,Thanks for your response.We will ask our relevant team to write a JS demo file for you.Once I get the demo file,I will get back to you again.

                  Comment


                  • #10
                    hEINSTEIN ,Thanks for your time to wait for our further response. Please download the demo file which supports to fill form field name in form field automatically without the file extension included:
                    http://sync-us.foxitsoftware.com/iss/JS/testfile.pdf
                    Any further questions or concerns,please contact us any time.


                    Attached Files
                    Last edited by Lisa_lee; 10-20-2020, 11:24 AM.

                    Comment


                    • #11
                      Originally posted by hEINSTEIN View Post
                      Lisa_lee Could you perhaps help me with getting rid of the file extension as well?
                      You can use this script:

                      Code:
                      function getname() {
                      
                      var sName = this.documentFileName;
                      aText = sName.split(".");
                      aText.pop();
                      this.getField("Text Field0").value = aText;
                      }
                      getname();

                      Comment


                      • #12
                        JRB Thanks for sharing.Actually,we have already created a demo file with the following scripts included which could meet user's requirement:

                        function getname()

                        {

                        var f = this.getField("Text Field0");

                        var cStr = this.documentFileName;

                        f.value = cStr.split(".");

                        }

                        getname();

                        The demo file could be downloaded from the link below:
                        http://sync-us.foxitsoftware.com/iss/JS/testfile.pdf


                        Comment


                        • #13
                          Thank you very much I appreciate the help.

                          Comment

                          Working...
                          X