Announcement

Collapse
No announcement yet.

Button to save the form

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

  • Button to save the form

    Hi,

    i'd like to have one button for the following two functions
    1. Prompt to "save as..." the form, automatically give the file name including the current date and a text field in the form. E.g. John fills the field "Name" and today is 09.12.2019. When he clicks on the button, he'll be prompted to save the file somewhere with name "20191209_John.pdf".
    2. By saving the file, it'll be read-only.

    Assuming the user is using Acrobat Reader.

    thanks.

  • #2
    luoqinran

    I'm checking this with our JS engineer internally and I'll update here once I got the reply. Thank you in advance.

    Comment


    • #3
      Answer to the second question:

      Code:
      var nButton = app.alert({ 
              cMsg: "This form will not be editable anymore. Do you want to continue?",
              cTitle: "Make Read-Only?", 
              nIcon: 2, nType: 2 
          });
      
      if (nButton == 4) {
          for (var i = 0; i < this.numFields; i++) {
              var fname = this.getNthFieldName(i);
              this.getField(fname).readonly = true; // makes all fields readonly
          }
      }

      Comment


      • #4
        luoqinran

        Please refer to the attached demo file and see if it helps:
        var d = new Date();
        var data = util.printd("mm-dd-yyyy",d);
        var f1 = this.getField("Text Field0");
        var mypath = "/E/" + data + f1.value +".pdf"; //file path and custom file name
        this.saveAs(mypath)

        Since the SaveAs function was disabled in version 8.3.2 and versions 9.0-9.7, I would encourage to email to [email protected] to get the current internal beta version of Foxit PhantomPDF 2019 Winter and test it out. I was told by our engineer that the SaveAs function has been supported again in current beta version.

        Regrading Read-only, currently it is not supported to set the whole document to be read only, it is supported to set specific field to be read only via using E.g. f.readonly = true.
        Attached Files

        Comment


        • #5
          Originally posted by cherry View Post
          luoqinran

          Please refer to the attached demo file and see if it helps:
          var d = new Date();
          var data = util.printd("mm-dd-yyyy",d);
          var f1 = this.getField("Text Field0");
          var mypath = "/E/" + data + f1.value +".pdf"; //file path and custom file name
          this.saveAs(mypath)

          Since the SaveAs function was disabled in version 8.3.2 and versions 9.0-9.7, I would encourage to email to [email protected] to get the current internal beta version of Foxit PhantomPDF 2019 Winter and test it out. I was told by our engineer that the SaveAs function has been supported again in current beta version.

          Regrading Read-only, currently it is not supported to set the whole document to be read only, it is supported to set specific field to be read only via using E.g. f.readonly = true.
          I am unable to get this script to work in my form. I am attempting to save the file using some of the field data as part of the file name but have been unsuccessful. Also windows likes to use backslashes rather than forward slashes for local file addresses. I added this script to the Push Button Actions section and no luck. Any help would be grateful. And the Demo file does not do anything.

          Also, how to I force a line break in text in a script? In Excel I use Chr (13) to force a next line, what is used in Foxit script to force a next line/return?

          Thank you,

          James
          Last edited by ThunderCrush; 06-19-2020, 07:42 PM.

          Comment


          • #6
            ThunderCrush

            Is it possible to send us the PDF document that includes your script and also check which version of Foxit PhantomPDF you're using on your side so we could better advise?
            Regarding "force a line break in text in a script", I'm checking internally and will update once I got the reply from our engineer. Thank you.

            Comment


            • #7
              Cherry,

              I am using Foxit Phantom PDF 9.7. I am unable to share the file.

              But in this script below how would I force a return in the email body so that after i complete a sentence the next sentence is started on the next line?

              var sendTo = this.getField("sendTo").value;
              var ccTo = this.getField("ccTo").value;
              var theSubject = this.getField("theSubject").value;
              var emailBody = this.getField("emailBody").value;

              this.mailDoc({
              bUI: false,
              cTo: sendTo,
              cCC: ccTo,
              cSubject: theSubject,
              cMsg: emailBody

              });

              Example:

              I want the ability for the email body to look something like this:

              "Today was a good day, tomorrow will be even better."

              "Strive for perfection, accept only excellence."


              But with using the script above the email body will look something like this:

              "Today was a good day, tomorrow will be even better. Strive for perfection, accept only excellence."

              I do not know how to force a return/line break at a specific location.

              Thank you

              Comment


              • #8
                Thank you in advance very help full for every user

                Comment


                • #9
                  ThunderCrush

                  I've submitted a ticket internally to check the mentioned JS with our engineer. Report ID#: QCPHANTOM-25626. Any further info needed or any update on this Report ID#, I'll keep you posted.

                  Thank you.

                  Comment


                  • #10
                    Cherry,

                    The JS for saveas das not work.

                    This is not working in FoxitPhantom Version: 9.7.1.29511 it doesn't do anything. Can you check by your JS engineer internally.
                    Thank you.

                    var d = new Date();
                    var data = util.printd("mm-dd-yyyy",d);
                    var f1 = this.getField("Text Field0");
                    var mypath = "/E/" + data + f1.value +".pdf"; //file path and custom file name
                    this.saveAs(mypath)

                    Comment


                    • #11
                      Please help me,
                      I want also to make JS button when I press to chouse a pdf or word and inserts it after the pdf (after the page) not as attached file.

                      Comment


                      • #12
                        alienfrik

                        Is it possible to provide us the PDF document in question that includes the JS button so we could test it further? Thank you.

                        Comment


                        • #13
                          I don't have the code, I don't know how to write it.

                          Comment


                          • #14
                            alienfrik ,I have submitted your request "Make JS button in PDF file when I press to choose a pdf or word and inserts it after the pdf (after the page) not as attached file" to our JS engineer to see whether this requirement can be achieved by JS scripts and how to write it(Report ID#PHANTOM-14781 ),I will get back to you for updates about it.

                            Comment


                            • #15
                              ThunderCrush

                              Regarding "QCPHANTOM-25626: Force a return in the email body", is it possible to create a demo file that includes the script so our engineer could further check on it? Thank you.

                              Comment

                              Working...
                              X