9 Replies Latest reply on Mar 19, 2015 3:54 PM by try67

    extract last page

    creditunion123 Level 1

      I have a form that could be 20 pages, 30 pages etc based on user input

      I want to be able to extract the last 15 pages of the document and email to the member through an action script or button or document action

       

      then the remaining docs (without the extracted disclosures) could be automatically saved - I have a trusted function already for that

       

      I have seen code to extract from the beginning but I want to extract from the last page - back

       

      Is there a way to do this

        • 1. Re: extract last page
          try67 MVP & Adobe Community Professional

          This code extracts the last 15 pages of a file as a new (temporary) file:

          this.extractPages(this.numPages-15, this.numPages-1);

          If you want you can also specify a file-path as the third parameter of this method.

           

          From your description it sounds like you then want to delete those pages from the original file. Extracting them doesn't do that. For that you can use this code:

          this.deletePages(this.numPages-15, this.numPages-1);

          • 2. Re: extract last page
            creditunion123 Level 1

            That works to extract – thank you

            Are you able to look at the rest of the code.  It is not quite working right

             

            So the code works to extract the file – awesome. The other code I have takes those pages and emails it to the person

             

            What it does not do is this:

            I would like to rename the file that is attached to the email and save just those pages in a folder – to verify to auditors we sent them

             

            Right now my code emails a file with a random name and the save function is saving the entire package (before extraction) as my file name

            It gives me an security error when it tries to save the oNewDoc – cause it is not calling my trusted function?

             

            var email = this.getField("FormValues.emailAddress_0").value

            var cSubLine = " Membership Terms and Conditions";

            var cBody = "Please find attached important information regarding the terms and conditions of your account. "

            var cCCAddr = email;

            var name = this.getField("FormValues.accountNames_0").value

            var folio =this.getField("FormValues.folioNumber_0").value

             

            var oNewDoc = this.extractPages(this.numPages-20, this.numPages-1);

            var cPath = myTrustedSaveFunc(this, "/HO-VM-SARUMAN/WorkSpaces/Public Folders/AccountOpening/TermsandConditions"+name + " " +folio +".pdf");

            var cEmailURL = "mailto:?cc=" + cCCAddr + "&subject=" + cSubLine + "&body=" + cBody;

             

            oNewDoc.saveAs(cPath);

             

            oNewDoc.submitForm();

             

             

             

            Linda Haworth

            [signature deleted by host]

            • 3. Re: extract last page
              try67 MVP & Adobe Community Professional

              Are you trying to save the extract file under this name? If so, don't use the "this" object, but oNewDoc in your trusted saveAs function.

              • 4. Re: extract last page
                creditunion123 Level 1

                Yes,  I am trying to save the extracted file under this name – so this?

                 

                var email = this.getField("FormValues.emailAddress_0").value

                var cSubLine = " Membership Terms and Conditions";

                var cBody = "Please find attached important information regarding the terms and conditions of your account. "

                var cCCAddr = email;

                var name = this.getField("FormValues.accountNames_0").value

                var folio =this.getField("FormValues.folioNumber_0").value

                 

                var oNewDoc = this.extractPages(this.numPages-20, this.numPages-1);

                myTrustedSaveFunc(oNewDoc, "/HO-VM-SARUMAN/WorkSpaces/Public Folders/AccountOpening/TermsandConditions"+name + " " +folio +".pdf");

                var cEmailURL = "mailto:?cc=" + cCCAddr + "&subject=" + cSubLine + "&body=" + cBody;

                 

                 

                oNewDoc.submitForm();

                 

                 

                Linda Haworth

                [signature deleted by host]

                • 5. Re: extract last page
                  creditunion123 Level 1

                  Worked.  Thanks.  Now to finish with the close and delete functions

                   

                  Thanks so much for your help

                   

                  Linda Haworth

                  [signature deleted by host]

                  • 6. Re: extract last page
                    creditunion123 Level 1

                    One last question

                    I am trying to put this into an action – which I have done with the script sent

                    Do you know if there is a way to script an action to sign the form

                     

                    I am looking for a way to create an easy workflow for staff that they

                    Click action or a toolbar item – that automatically

                    1. extracts pages and emails – script done

                    2. saves extracted pages to folder – script done

                    3. Deletes pages from  original document – you gave me script – just have not tested

                    4. Prompts user to get document signed via signature pad  - see no where to add script or action

                    5. Saves signed document into file folder one signed– script done

                     

                    Linda Haworth

                    [signature deleted by host]

                    • 7. Re: extract last page
                      try67 MVP & Adobe Community Professional

                      Have a look at the signatureSign method of the Field object.

                      • 8. Re: extract last page
                        creditunion123 Level 1

                        One last question.  I have the form working pretty much the way I want

                        Can I do the same process if I want the extracted document to Print - not email

                         

                        I have this - which is the extract rename and save file- email - close and delete (works awesome)

                         

                        this.getField("Emailed Docs").value = "Emailed Terms and Conditions"
                        var email = this.getField("FormValues.emailAddress_0").value
                        var cSubLine = "Membership Terms and Conditions";
                        var cBody = "Please find attached important information regarding the terms and conditions of your account ."

                        var cCCAddr = email;
                        var name = this.getField("FormValues.accountNames_0").value
                        var folio =this.getField("FormValues.folioNumber_0").value

                         

                        var oNewDoc = this.extractPages(this.numPages-20, this.numPages-1);
                         
                        var cEmailURL = "mailto:?cc=" + cCCAddr + "&subject=" + cSubLine + "&body=" + cBody;

                         

                        myTrustedSaveFunc(oNewDoc, "/HO-VM-SAR/WorkSpaces/Public Folders/AccountOpening/TermsandConditions/" +"Account Agreement "+name + " " +folio +".pdf");

                        oNewDoc.submitForm({
                             cURL: cEmailURL,
                             cSubmitAs:"PDF",
                             cCharSet:"utf-8"});

                         

                        oNewDoc.closeDoc(true);

                         

                        this.deletePages(this.numPages-20, this.numPages-1);

                        I want a similar function if the member does not want the terms emailed but printed for them

                         

                         

                        this.getField("Emailed Docs").value = "Printed Terms and Conditions and handed to Member"

                        If printed I don't need them saved


                        var oNewDoc = this.extractPages(this.numPages-20, this.numPages-1);

                        oNewDoc.print({
                        bUI: true,
                        bSilent: true,
                        bShrinkToFit: true,
                        nStart: 0,
                        nEnd: 20
                        });

                         

                        oNewDoc.closeDoc(true);
                         
                        this.deletePages(this.numPages-20, this.numPages-1);

                         

                        but I cant seem to get it to print the extracted docs - does not like me putting oNewDoc.print and does not use this.print and it does not like if I just try to print pages nStart - 20, nEnd -1

                        so I am stumped.

                        • 9. Re: extract last page
                          try67 MVP & Adobe Community Professional

                          Once you create a new file by extracting the pages you should not be using the "this" object any more, at all. If you want to refer to the original file then you need to have a variable pointing to it before extracting the pages. Something like this:

                           

                          var originalDoc = this;

                          // extract pages and print them

                          originalDoc.deletePages(this.numPages-20, this.numPages-1);

                           

                          What goes wrong when you try to print the file? Is there an error message? Your nEnd parameter is wrong, by the way. It can only be 19, as the page numbers are zero-based, remember. You also need to read the rest of the documentation for print carefully. For example under nEnd it says:

                          If nStart and nEnd parameters are used, bUI must be false.