8 Replies Latest reply: Mar 29, 2013 2:34 PM by TheSilverSmith RSS

    Export pdf and fdf in same email

    MissionHill Community Member

      Having trouble trying to figure out how to have a submit button mailout 2 attachments on the same email generated from mailForm() and mailPDF(). Also having trouble trying to get the generated  .FDF file to only contain data of selected fields

       

       

      Current SOURCE:

       

      var RE = this.getField("RequestExcel").value;

      var S = this.getField("SubmitPdf").value;

       

      if(RE == true)

      {

      this.mailForm({bUI: true, cTo: "x.x@gmail.com", cCc:"" , cSubject: "TestForm", CMsg:""});

       

      }

       

      if(S == true)

      {

      this.mailDoc({bUI: true, cTo: "x.x@gmail.com", cCc:"" , cSubject: "TestForm", CMsg:""});

      }

        • 1. Re: Export pdf and fdf in same email
          MissionHill Community Member

          .fdfFormatOptions.jpg

           

          export Options for .fdf  file

          • 2. Re: Export pdf and fdf in same email
            MissionHill Community Member

            mailto:email@domain.com?subject=TestForm&body=see+RequestExcel.FDF&attachment=HoldFDF+FlatForm.PDF&attachment=HoldPDF

            • 3. Re: Export pdf and fdf in same email
              MissionHill Community Member

              The app.newFDF()is a typical example of a security restricted method that needs a

              privileged context in which to run. Place the following script in a .js in the User (or App)

              JavaScript folder.

              trustedNewFDF = app.trustedFunction( function (FileLocation)

              {

              // additional code may appear above

              app.beginPriv(); // explicitly raise privilege

              app.newFDF( FileLocation );

              app.endPriv();

              // additional code may appear below.

              })

               

               

              Now, after restarting Acrobat, execute the function trustedNewFDF() from anywhere,

              for example, a mouse up action from a push button.

              • 4. Re: Export pdf and fdf in same email
                MissionHill Community Member

                So I've got my javascript array (var seatsArray = [];), let's say it has some contents. I want to write the contents of that array to a .txt file on the server when the user clicks a button. The text file will not already exist so it needs to be created.

                Also, if anyone knows how I could allow the user to specify the name of the text file to be created by typing it in a text area, that would be great.

                Any ideas?

                Many thanks John

                EDIT:

                Added the suggested code, however, nothing happens when I hit save?

                <form id="my_form" action="">
                <input type="text" id="file_name" rows="1" cols="20">
                <a href="javascript: SubmitForm()">Save</a>
                </form>

                <script type="text/javascript">
                function submitform();
                {
                var d = seatsArray.join();
                var url = "/txtfiles/"+d + "&file_name=" +
                document
                .getElementById("file_name").value;

                document
                .getElementById("my_form").action = url;
                document
                .getElementById("my_form").method = "POST";
                document
                .getElementById("my_form").submit();
                }
                </script>

                That is all in the body section.

                Thanks

                • 5. Re: Export pdf and fdf in same email
                  MissionHill Community Member

                  var CSV = new String();

                        

                   

                  for (var j=0; j < this.numFields; j++)

                          {

                              CSV+this.getField(j)+",";

                          }

                   

                         

                   

                   

                   

                  var FDF = this.createDataObject(ExportExcel, CSV);

                   

                  //Note cMIMEType and cCryptFilter are optional parameters

                   

                  this.exportDataObject(FDF);

                   

                  //Note cDIPath and bAllowAuth are optional parameters

                  • 6. Re: Export pdf and fdf in same email
                    MissionHill Community Member

                    //Semi Troll Post :/

                     

                    *Decided 2 take a different route and run a VBA macro in outlook...
                    *ALready can auto save .XFDF [.xml] (designated form field data) into designated folder in outlook.
                    *End goal iz to run a macro to load XFDF data into pre-made excel file

                    //

                     

                     

                    Code i have right now will load pre made .xls file if excel is already running....however it would be much more ideal 2 get code to open&load designated .xls file even if an instance of excel is not currently running

                     

                    CoDE\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

                     

                     

                    Sub WorkOnAWorkbook()

                     

                    Dim oXL As Excel.Application

                    Dim oWB As Excel.Workbook

                    Dim oSheet As Excel.Worksheet

                    Dim oRng As Excel.Range

                    Dim ExcelWasNotRunning As Boolean

                    Dim WorkbookToWorkOn As String

                     

                    'specify the workbook to work on

                    WorkbookToWorkOn = "C:\Users\House\Desktop\XXX Test Forms\TestForms\XXX.xls"

                     

                    'If Excel is running, get a handle on it; otherwise start a new instance of Excel

                    On Error Resume Next

                    Set oXL = GetObject(, "Excel.Application")

                     

                    If Err Then

                       ExcelWasNotRunning = True

                       Set oXL = New Excel.Application

                    End If

                     

                    On Error GoTo Err_Handler

                     

                    'If you want Excel to be visible, you could add the line: oXL.Visible = True here; but your code will run faster if you don't make it visible

                     

                    'Open the workbook

                    Set oWB = oXL.Workbooks.Open(FileName:=WorkbookToWorkOn)

                     

                    'Process each of the spreadsheets in the workbook

                    For Each oSheet In oXL.ActiveWorkbook.Worksheets

                       'put guts of your code here

                       'get next sheet

                    Next oSheet

                     

                    If ExcelWasNotRunning Then

                      oXL.Quit

                    End If

                     

                    'Make sure you release object references.

                    Set oRng = Nothing

                    Set oSheet = Nothing

                    Set oWB = Nothing

                    Set oXL = Nothing

                     

                    'quit

                    Exit Sub

                     

                    Err_Handler:

                       MsgBox WorkbookToWorkOn & " caused a problem. " & Err.Description, vbCritical, _

                               "Error: " & Err.Number

                       If ExcelWasNotRunning Then

                           oXL.Quit

                       End If

                     

                    End Sub

                     

                    Sub Test()

                       MsgBox ("Hello world *****!!!!")

                     

                    End Sub

                    Sub GenerateExcel()

                    Dim Wb As String

                        Dim wbPath As String

                         'Create variable to instantiate a new Excel instance

                        Dim xl As New Excel.Application

                     

                         'hide stuff from user

                        Application.ScreenUpdating = False

                     

                         'capture the new workbook's name & path

                        Wb = ActiveWorkbook.Name

                        wbPath = Workbooks(Wb).Path

                     

                         'Close the new workbook before it becomes visible

                        Workbooks(Wb).Close False

                     

                         'Open the workbook in the new instance of Excel and set visible

                         'If the workbook doesn't exist (a new workbook) then

                         'create a new one in the new Excel instance

                     

                        On Error Resume Next

                        xl.Workbooks.Open wbPath & "\" & Wb

                        If Err.Number > 0 Then

                            Err.Clear

                            xl.Workbooks.Add

                        End If

                        xl.Visible = True

                     

                         'Discard the object variable and unhide from user

                        Set xl = Nothing

                        Application.ScreenUpdating = True

                    End Sub

                    • 7. Re: Export pdf and fdf in same email
                      MissionHill Community Member

                      Sub fdfimport()
                        Dim OutSH As Worksheet
                        Dim Fname As Variant
                        Fname = Application.GetOpenFilename("FDF File (*.FDF),*.fdf", , _
                        "Select Text Data File")
                        Open Fname For Input As #1
                        Do While Not EOF(1)
                        Line Input #1, myvar
                        arr = Split(myvar, Chr(10))
                        arr2 = Split(arr(4), "/V")

                        If InStr(1, myvar, "(Contact)") > 0 Then
                        Set OutSH = Sheets("Contact")
                        outrow = OutSH.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
                        For i = 1 To 8
                        placer = InStr(1, arr2(i), ")")
                        OutSH.Cells(outrow, i).Value = Left(arr2(i), placer - 1)
                        Next i
                        
                        Else
                        Set OutSH = Sheets("NoContact")
                        outrow = OutSH.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
                        For i = 1 To 12
                        placer = InStr(1, arr2(i), ")")
                        OutSH.Cells(outrow, i).Value = Left(arr2(i), placer - 1)
                        Next i
                        
                        End If
                        
                        
                        Loop
                        Close #1
                       
                        
                        
                        Sheets("Contact").Cells.Replace what:="(", replacement:=""
                        Sheets("NoContact").Cells.Replace what:="(", replacement:=""
                      End Sub

                      • 8. Re: Export pdf and fdf in same email
                        TheSilverSmith Community Member

                        Don't know if this is of any use to you but I have just written a little utility that lets you open multiple XFDF files and load them into a pre-existing (and closed) Excel spreadsheet. It needs to be configured with a mapping of the form fields to the spreadsheet columns but it's published free and may help you... you can look at it at http://www.tarrget.info/XFDF2XL

                         

                        Cheers, Anthony