9 Replies Latest reply on Aug 15, 2014 12:39 PM by try67

    Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");

    kecsushil Level 1

      Hi,

      I have pdf created in livecycle and coded in Javascript. Currently this pdf is placed in the shared location from where users can access. When users hit the submit button then PDFCreator installed on user's machine creates a scanned pdf and place it on the local machine. This scan pdf is then embedded into the main pdf using privileged javascript function (doc.importdataobject("myPDF","/c/temp/outfile.pdf");).
      Now, I want to place the main pdf on the server so that user can access the pdf using URL.
      When user access the pdf using URL and hit the submit button, it's creating scan pdf on the user machine, but it's failing on the import statement -doc.importdataobject("myPDF","/c/temp/outfile.pdf");.


      I am not sure whether this is access issue or I need to do something else.

       

      The path /c/temp/outfile.pdf must be local machine path but I am assuming import statement is looking on server directory.

       

      If I remove the path from the import statement, it pops up a dialog box for browse. After selecting the outfile.pdf it works fine. But I can't ask users to follow this process.


      email: kec.sushil@gmail.com

      Please help.

        • 1. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
          try67 MVP & Adobe Community Professional

          From the documentation of the importDataObject method:

          Note: If the cDIPath parameter is specified, this method can only be executed during a batch or

          console event, or through an external call (for example, OLE). See Privileged versus non-privileged

          context for details.

          What this in effect means is that if you want to use this command from a button and specify the cDIPath parameter it has to call a script in a trusted context, like one that is installed on the user's local machine. Otherwise you can't specify it yourself, but the user will need to select it manually.

          • 2. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
            kecsushil Level 1

            What this in effect means is that if you want to use this command from a button and specify the cDIPath parameter it has to call a script in a trusted context, like one that is installed on the user's local machine. Otherwise you can't specify it yourself, but the user will need to select it manually.

             

            I have written import statement in a trusted javascript function and placed it on the user machine under the following location:

            C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts

             

             

            Function:

             

            var myReadDoc = app.trustedFunction(function(doc,thepath) {
            app.beginPriv();
            var mynewname = "testing123";
            var thedoc = doc.importDataObject(mynewname,"C:\\TEMP\\print\\OUTFILE.pdf");

             

            console.println("status of the import is :" + thedoc);
            console.println("Dumping all data objects in the document.");
            var stat = "good";
            if (thedoc == true) {
                      try{
                var d = doc.dataObjects;
              for (var i = 0; i < d.length; i++)
               console.println("DataObject[" + i + "]=" + d[i].name);
                       }catch(e){
                        stat = "Bad";
                        }

            }
            if (thedoc == false) {
                       stat = "Bad";
                      }
            app.endPriv();
                    return(stat);
            });

            • 3. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
              try67 MVP & Adobe Community Professional

              Your file-path syntax is incorrect. Use the syntax style from your original code.

              • 4. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                kecsushil Level 1

                var thedoc = doc.importDataObject(mynewname,"/C/TEMP/print/OUTFILE.pdf");

                 

                Still, same issue.

                 

                After importing, I have a code to opendataobject and it's throwing error (JavaScript console print).

                 

                ************************************************

                JavaScript console print:

                 

                status of the import is :true
                Dumping all data objects in the document.
                DataObject[0]=testing123
                After myReadDoc:goodstat:good
                Before openDataObject

                RaiseError: File does not begin with '%PDF-'.
                Doc.openDataObject:1342:XFA:topmostSubform[0]:#pageSet[0]:PageArea1[0]:Submit[0]:click
                ===> File does not begin with '%PDF-'.

                • 5. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                  try67 MVP & Adobe Community Professional

                  I don't understand. Is the file being imported correctly? Opening it is another matter...

                  • 6. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                    kecsushil Level 1

                    I will explain what I found in my analysis, before that I want to ask you one question.

                    Is there any other way to import the pdf (from local machine) into another pdf (placed on the server and access through URL)? If yes, please share with me.

                     

                    ----------------------------------------

                    Even I had the same question. So, after importing the pdf I saved it.

                     

                    After opening the OUTFILE.pdf, Adobe says corrupt file.

                     

                    Which means importing is happening but because of some unknown reasons it is not able to find the specified path so creating (importing) an corrupt/dummy OUTFILE.pdf into the pdf.

                     

                    So, when event.target.opendataobject("myPDF") is executed, its throws that error.

                     

                    Thanks Gilad for your responses. I hope, you will understand when things are not going our way, its very hard to explain it.

                    • 7. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                      try67 MVP & Adobe Community Professional

                      Can you open that file directly in Acrobat? It sounds to me like it's

                      corrupt...

                       

                      You can also import a file into a PDF using the Attach File commenting tool.

                      • 8. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                        kecsushil Level 1

                        OUTFILE.pdf which is placed in the location ,"/C/TEMP/print/, isn't corrupt.

                         

                        One more question:

                         

                        If I am trying to import the OUTFILE.pdf from the location "/C/TEMP/print/OUTFILE.pdf" and this location is not accessible because of any reasons, then what will be imported as result of below statement:

                        var thedoc = doc.importDataObject(mynewname,"/C/TEMP/print/OUTFILE.pdf");

                        • 9. Re: Access issue: doc.importdataobject("myPDF","/c/temp/outfile.pdf");
                          try67 MVP & Adobe Community Professional

                          Nothing, it will through an error message.

                          Also, keep in mind that the importDataObject method does not return a

                          Document object, only true in case it was successful.