6 Replies Latest reply on Jun 2, 2009 7:50 AM by Jan Babicky

    How do i use Select file dialog box in acrobat 7.0 using js?

    (subha_oviya)
      hi,

      I need to use file selecting dialog box in acrobat 7.0.

      i already used in indesign scripting like

      var f=File.selectDialog("Select a indesign file");

      this will return that selected file path.

      how can i use it in same acrobat 7.0

      regards,
      Subha_oviya
        • 1. Re: How do i use Select file dialog box in acrobat 7.0 using js?
          Patrick Leckey Level 3
          If you call importDataObject with no path specified, it will open a file selection dialog and then embed that file as a dataObject (since you cannot directly access external files from a PDF).
          • 2. Re: How do i use Select file dialog box in acrobat 7.0 using js?
            George_Johnson MVP & Adobe Community Professional
            What do you want to do with the selected file?

            George
            • 3. Re: How do i use Select file dialog box in acrobat 7.0 using js?
              (subha_oviya) Level 1
              hi george,

              I need to read a CSV file and do some operaion.

              1) i select a file selection dialog box.
              2) choose that particular csv file.
              3) Read the contets of the CSV file. (it consist of PDF file paths)
              4) Open the PDF and do some operation.

              So i need a file selection dialog box and import the contents of the csv file in a object.

              by
              Subha_Oviya
              • 4. Re: How do i use Select file dialog box in acrobat 7.0 using js?
                JendaDH

                The same method works for Acrobat 9, however the "description" section is not filled the same way as it was in Acrobat 8. Any ideas how to do that?

                If the description is not unique, the attached file gets overwriten with the latest attached file.

                 

                J

                • 5. Re: How do i use Select file dialog box in acrobat 7.0 using js?
                  Patrick Leckey Level 3

                  I just tested this with Acrobat 9.1.1 and I'm not seeing the same behaviour as you.

                   

                  Also, multiple files having the same description is quite possible.  It is the "name" field that needs to be unique.

                   

                  Can you give me steps to reproduce the behaviour you are seeing so that I can look into it?

                  • 6. Re: How do i use Select file dialog box in acrobat 7.0 using js?
                    Jan Babicky Level 1

                    Hi Patrick,

                     

                    sorry for late reply, it has been quite busy these days.

                    So, I have a form that has at the end section for different file attachments. Some of them are unique types, some of them are repetitive sections.

                    The script does take ID code from the unique section and set it as name. In repetitive section (other attachments) there is time stamp being calculated.

                     

                    Here is how the section looks visually (not sure if that helps)

                    http://www.cyprd.cz/tmp1.jpg

                     

                    Here is the script for the add button:

                    (the script does check if the same ID exists /used for replacing older version or incorectly attached file/, also specific file extensions are alowed.)

                     

                    var myDoc = event.target;


                    myDoc.importDataObject(kod1.rawValue);

                     

                    var dobj=myDoc.dataObjects;
                    if(dobj)
                    {
                        for (var i = 0; i < dobj.length; i++){       
                            if(dobj[i].name==kod1.rawValue)
                            {
                                //definice povolenzch pripon
                                var pripony = new Array(8);
                                    pripony[0]= "DOC";
                                    pripony[1]= "RTF";
                                    pripony[2]= "PDF";
                                    pripony[3]= "TXT";
                                    pripony[4]= "JPG";
                                    pripony[5]= "PNG";
                                    pripony[6]= "GIF";
                                    pripony[7]= "JPEG";
                           
                                var soubor = dobj[i].path;
                                var pripona = soubor.split(".").pop().toUpperCase();
                                var schvaleno = 0;
                                var pocetpripon = pripony.length
                                for (var i=0; i<pocetpripon; i++)
                                {
                                    if(pripona==pripony[i])
                                    {
                                        schvaleno =1;
                                    }
                                }
                       
                                if(schvaleno)
                                {
                                    filename1.rawValue =soubor;
                                    ocr1.presence="visible";
                                }
                                else
                                {
                                    myDoc.removeDataObject(kod1.rawValue);
                                    xfa.host.messageBox("Vložit lze pouze soubory s příponou DOC, RTF, PDF, TXT, JPG, PNG, GIF");
                                    ocr1.presence="hidden";
                                    filename1.rawValue="";
                                }
                            }
                        }
                    }

                     

                    For some reason, in acrobat 9 (or reader 9) this does attach the file, however the description section, where the name is stored is left blank, therefore there is only one attachment in the PDF.

                     

                    Any suggestions are highly appreciated.

                     

                    Thanks in advance,

                     

                    Jan