26 Replies Latest reply on Apr 22, 2014 11:07 AM by kecsushil

    RaiseError: File does not begin with '%PDF

    kecsushil

      I have an application which has below script:

      var oDoc = event.target.openDataObject("testing123");

       

      This script works fine if I run it on my local machine.

       

      But I am planning to place the pdf (application) on the server. After placing the pdf on the server, I tried to open the pdf through local browser, I got an error 'File does not begin with '%PDF'.

       

      I added one line:

       

      var thePath = oDoc.path;

       

      After running, I got local machine path where pdf is placed. On Server, no path is coming in the debugger.

       

      Server doesn't have Acrobat install on it. Each user has acrobat to open the pdf

       

      Please advise.

        • 1. Re: RaiseError: File does not begin with '%PDF
          Bernd Alheit Adobe Community Professional & MVP

          Where did you add the Javascript code?

          • 2. Re: RaiseError: File does not begin with '%PDF
            kecsushil Level 1

            I have a Submit button. There I have written this script. Then I place this pdf on the server so that the user can access the pdf through IE browser.

             

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

            There are some javascript files which exist on each local machine. This script has doc.importDataObject.

             

            I think this may cause this issue.

             

            I have very limited knowledge on importDataobject and openDataobject.

             

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

             

            Working Scenario:

             

            If I place the PDF on the local machine and hit submit, everything works fine.

            • 3. Re: RaiseError: File does not begin with '%PDF
              Bernd Alheit Adobe Community Professional & MVP

              Why did you use openDataObject in a submit button? What is the reason for this?

              • 4. Re: RaiseError: File does not begin with '%PDF
                kecsushil Level 1

                I just need the timestamp of the dataobject.

                 

                var oDoc = event.target.openDataObject("testing123");

                var theDate = oDoc.info.creationDate;

                 

                If I give command to see the path of the event.target - it displays the path of the Acrobat pdf (parent) -- placed on local or the server machine

                 

                 

                going one step ahead, if want to see the path of the embedded pdf on local and server location.

                like -

                 

                pdf run on local machine:

                var oDoc = event.target.openDataObject("testing123");

                var path = oDoc .path;

                var theDate = oDoc.info.creationDate;

                 

                This works fine on local machine- retuns the path.

                 

                But if I place the same pdf on server, I get RaiseError: File does not begin with '%PDF

                • 5. Re: RaiseError: File does not begin with '%PDF
                  Test Screen Name Most Valuable Participant

                  Examine the PDF. A valid PDF does have %PDF as its first four characters. You need to establish if the message is spurious, or file bad.

                  • 6. Re: RaiseError: File does not begin with '%PDF
                    kecsushil Level 1

                    I have a pdf which has a button that I have given name as 'Submit'.

                     

                    This Submit button has javascript which fires when I hit submit button.

                     

                    As a part of Submit button javascript, I need -

                    1. Create the static pdf of the Acrobat form using PDFCreator - on the local machine

                    2. And then import this static pdf in the Acrobat form (parent)

                     

                    After import, i need the creation date of the embedded pdf (object), to do some other stuff.

                     

                    This works fine if I use the Arobat form (parent pdf ) on the local machine.

                    Here I explain what happens when I use the PDF on the local machine.

                    -> Fill the data on the Acrobat form (pdf) designed in the Adobe LiveCycle

                    -> Hit submit button

                    -> Creates the static pdf on the local machine using PDFCreator

                    -> Import this pdf in the parent pdf using doc.importdataobject(myNewName, thePath) - thePath refers local machine path, myNewName = "testing123" -- this is in javascript file placed on the javascript folder for Acrobat under c drive

                    ->When import returns true, get the creation date using event.target.opendataobject("testing123") -- Submit button script

                     

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

                     

                    Now if I move Acrobat form (pdf) to server, then event.target.opendataobject("testing123") fails, throws RaiseError: File does not begin with '%PDF.

                     

                    I am not sure that keeping parent file on server and trying to embedded the file(pdf) which exists on local machine cause of this error.

                     

                    Is it possible to embbed the pdf file (which exists on local machine) to another file which exists on server, when accessing through IE browser?

                    if yes, then why event.target.opendataobject("testing123") fails?

                    • 7. Re: RaiseError: File does not begin with '%PDF
                      kecsushil Level 1

                      Hi,

                       

                      I read your some of the solutions provided by you and looking for positive response for my problem.

                       

                      I have a dynamic pdf designed in LiveCycle which has buttons and javascript.

                       

                      I kept this pdf on the server so that user can access this through url.

                       

                      ONce the pdf is opened in the acrobat using URL, user can enter data. After filling the form, user submits the form by clicking on a button named submit.

                      This submit button has javascript. Some javascript files are placed on the user's machine under javascript folder for Acrobat.

                       

                      Once the user hits the submit button, PDFCreater generates the Static pdf and store it on user machine (c/temp).

                       

                      There is a function in one of the javascript files to import this static pdf.

                       

                      var oDoc = Doc.importDataObject("testing", thePath);  -- thePath = c/temp/test.pdf

                       

                      Console shows the import status true.

                       

                      But when I try to open this 'testing' data object, I get RaiseError: File does not begin with '%PDF

                       

                      Just to see what file was imported, I used exportDataObject("testing"), the pdf was corrupted. Because of this openDataObject("testing") throws above error.

                       

                      So, my question is how to import a pdf (stored on local machine) into a pdf (parent) stored on the server?

                      • 8. Re: RaiseError: File does not begin with '%PDF
                        try67 MVP & Adobe Community Professional

                        Have you manaully verified that the files generated by PDFCreator are valid PDF files? In other words, are you able to open them directly in Acrobat?

                        • 9. Re: RaiseError: File does not begin with '%PDF
                          Bernd Alheit Adobe Community Professional & MVP

                          kecsushil wrote:

                           

                          Once the user hits the submit button, PDFCreater generates the Static pdf and store it on user machine (c/temp).

                          How did you execute PDFCreator ?

                          • 10. Re: RaiseError: File does not begin with '%PDF
                            Test Screen Name Most Valuable Participant

                            Replies 5 and 8 have made specific suggestions. Please let us know the results.

                            • 11. Re: RaiseError: File does not begin with '%PDF
                              kecsushil Level 1

                              Yes, I verified that PDF generated by PDFCreater is valid.

                               

                              The issue is when parent pdf (opened through browser placed on server) try to import this pdf, it gets corrupted. I verified this by using exportDataObject.

                               

                              Is something that parent pdf is on server and the pdf which is embedded is on local machine, creates any issue or cause? 

                              • 12. Re: RaiseError: File does not begin with '%PDF
                                try67 MVP & Adobe Community Professional

                                Is something that parent pdf is on server and the pdf which is embedded is on local machine, creates any issue or cause?

                                That should not be an issue.

                                 

                                Is it possible for you to share the file(s) in question?

                                • 13. Re: RaiseError: File does not begin with '%PDF
                                  kecsushil Level 1

                                  Sorry, I can't share these files.

                                   

                                  But if I place the Parent pdf on local machine, everything is working fine.

                                   

                                  But I want to place the Parent pdf on the server. PDFCreator is installed on users machine. So it creates a static copy of the Acrobat form on the local machine. And then this static pdf is imported to the Acrobat form using doc.importdataobject(myName, thepath).

                                   

                                  thePath refers to the location where static pdf is created by PDFCreator on the user's machine.

                                   

                                  If I want to see DataObject - it shows testing123. So this works fine.

                                   

                                  IF I want to open this dataObject, using event.target.openDataObject("testing123").

                                   

                                  it throws RaiseError: File does not begin with '%PDF.

                                  • 14. Re: RaiseError: File does not begin with '%PDF
                                    try67 MVP & Adobe Community Professional

                                    This sounds to me like a bug in the way PDFCreator embeds the file as an

                                    attachment.

                                    • 15. Re: RaiseError: File does not begin with '%PDF
                                      kecsushil Level 1

                                      Not sure.

                                       

                                      But it works fine if I do this process on the local machine.

                                       

                                      if I move Parent pdf to Server, it creates issue.

                                       

                                      Please help me to point this issue in PDFCreator.

                                      • 16. Re: RaiseError: File does not begin with '%PDF
                                        Test Screen Name Most Valuable Participant

                                        My suggestion is that you work on a dummy form and dummy data so you have something you can share. You seem to have reached the limit of what people can suggest without concrete examples.

                                        • 17. Re: RaiseError: File does not begin with '%PDF
                                          kecsushil Level 1

                                          Hi,

                                          I was reading about 'importDataObject' and here is the information:

                                          The following code displays a File Open dialog for the user to select the file to attach, and then gives the file attachment the name "MyFile."

                                          this.importDataObject("MyFile");

                                           

                                          My code has - var oDoc = Doc.importDataObject("testing", thePath);  -- thePath = "/c/temp/print/test.pdf"

                                           

                                           

                                          So just for try, I removed variable thePath from the syntax. new script is -

                                          var oDoc = Doc.importDataObject("testing");  -- this will give pop up to browse and select the pdf

                                           

                                          Then I access the pdf through IE browser using below link - (sample)

                                          http://machinename.xyz.com:8082/myFile.pdf

                                           

                                          I clicked the button that fires the script to create the static pdf on local machine (c:/temp/print/test.pdf) using PDFCreator and then import the same pdf using importDataObject.

                                           

                                          This time, I got pop up to browse and select the second pdf to import. I did in the same way. I selected the pdf and majic happened, it worked fine.

                                           

                                          So, thePath -- ("/c/temp/print/test.pdf") creates the problem.

                                           

                                          Please let me know how to tackle this situation.

                                           

                                          I can't ask user each and every time to select the pdf to import.

                                           

                                           

                                           


                                          • 18. Re: RaiseError: File does not begin with '%PDF
                                            try67 MVP & Adobe Community Professional

                                            Up until now I was under the impression that you were talking about openDataObject, not importDataObject, but looking back it seems you were someonetimes talking about one, sometimes about the other, and sometimes about both.

                                             

                                            The two methods are very different and have very different security restrictions. You need to be more clear about the situation and about the problem you're having.

                                             

                                            If you had a look at the documenation of importDataObject then you should have seen this note there as well:

                                            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. See the event object for a discussion of JavaScript events.

                                            • 19. Re: RaiseError: File does not begin with '%PDF
                                              Bernd Alheit Adobe Community Professional & MVP

                                              kecsushil wrote:

                                               

                                              So, thePath -- ("/c/temp/print/test.pdf") creates the problem.

                                               

                                              Please let me know how to tackle this situation.

                                              How did you create the file test.pdf ?

                                              • 20. Re: RaiseError: File does not begin with '%PDF
                                                kecsushil Level 1

                                                Hi,

                                                 

                                                test.pdf is created by PDFCreator installed on the user's (local) machine, before importing.

                                                 

                                                C:\TEMP\print - is set as a location where PDFCreator stores the pdf.

                                                • 21. Re: RaiseError: File does not begin with '%PDF
                                                  kecsushil Level 1

                                                  Thanks for reply.

                                                   

                                                  When I faced this issue, I thought script event.target.openDataObject("test") has some problem.

                                                   

                                                  But after analysis, I found that its working fine.

                                                   

                                                  var oDoc = Doc.importDataObject("testing", thePath); this has path issue.

                                                   

                                                  I did more analysis on Doc object path. I got the server path/ link from which I am accessing the pdf in the browser.

                                                   

                                                  Here I have one question.

                                                   

                                                  When Doc object path is Server location, then from where importDataObject will pick the file if I provide value to thePath varaible as  "/c/temp/print/test.pdf".

                                                   

                                                  importDataObject script is written in the trusted function in JS file placed outside the pdf under the Javascript folder for Acrobat on LOcal machine -> C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts\importFile.js

                                                  • 22. Re: RaiseError: File does not begin with '%PDF
                                                    Bernd Alheit Adobe Community Professional & MVP

                                                    PDFCreator creates the document and when this is finished the user imports the document?

                                                    • 23. Re: RaiseError: File does not begin with '%PDF
                                                      kecsushil Level 1

                                                      Yes.

                                                       

                                                      Doc.importDataObject("test", thePath) -- imports that pdf from local machine.

                                                      • 24. Re: RaiseError: File does not begin with '%PDF
                                                        kecsushil Level 1

                                                        Thanks for all your responses.

                                                         

                                                        Still I am not able to resolve this issue.

                                                         

                                                        Below I am explaining what is there in current scenario: (everything on local machine - PDF, Acrobat install, PDFcreator, JS files )

                                                         

                                                        I have PDF designed in LiveCycle. This pdf has a 'Complete' button and some code which fires on click.

                                                         

                                                        Here I am going to explain about some code written on click event:

                                                         

                                                        Once the user fills the entries on the form, he/she clicks on the Complete Button.

                                                         

                                                        event: click     language: javascript      runAt: client    -- Script editor LiveCycle

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

                                                         

                                                        1. Call is made to a function (written in the javascript file - C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts\importFile.js) which creates a static pdf of the form and save it on the local machine (/c/temp/print/test.pdf).

                                                         

                                                        2. After this, another call is made to a function written in the same JS files (path above mentioned) to import the dataobject.

                                                        var file = "/c/temp/print/test.pdf";

                                                         

                                                        var status = myReadDoc(event.target, file);

                                                         

                                                         

                                                        JS file code:

                                                        --> start

                                                         

                                                        var myReadDoc = app.trustedFunction(function(doc,thePath)){
                                                          app.beginPriv();
                                                          var mynewname = "testing123";
                                                         

                                                          var theDoc = doc.importDataObject(mynewname, thePath);
                                                          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. Once the import is done, there is need to get the creation date of the imported dataObject

                                                         

                                                        var oDoc = event.target;

                                                        var getObject = oDoc.openDataObject("testing123");

                                                        var theDate = getObject.info.CreationDate;

                                                         

                                                        -------------------------------This works fine on the local machine------------------------

                                                         

                                                        I am planning to move the PDF on the server keeping everything like Acrobat install, JS files and PDFCreator on the local machine so that user can access it using URL.

                                                         

                                                        After accessing the PDF through URL, I hit the Complete button and Debugger shows RaiseError message (RaiseError: File does not begin with '%PDF' ).

                                                         

                                                        I did analysis on this and found importDataObject isn't importing the test.pdf. It imports something which is not pdf. But the path has only one file (test.pdf).

                                                        Because of which openDataObject throws RaiseError.

                                                         

                                                        If I remove thePath variable from importDataObject, I got pop up to browse the file on the local machine and works fine.

                                                         

                                                        I am in confussion why importDataObject is not picking test.pdf in this scenario, whereas it worked when pdf is accessed on the local machine.

                                                         

                                                        Please let me know in case you need more information. I desperately need answer to this issue.

                                                         

                                                         

                                                        Thanks in advance.

                                                        • 25. Re: RaiseError: File does not begin with '%PDF
                                                          Bernd Alheit Adobe Community Professional & MVP

                                                          How did you create the static pdf of the form with Javascript?

                                                          • 26. Re: RaiseError: File does not begin with '%PDF
                                                            kecsushil Level 1

                                                            Using passing printer name to a function written in the Javascript file.

                                                             

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

                                                             

                                                             

                                                            var doSilentPrint = app.trustedFunction(function(printer) {

                                                             

                                                             

                                                            app.beginPriv();

                                                                                 var pp = event.target.getPrintParams();

                                                                                pp.interactive = pp.constants.interactionLevel.automatic;

                                                                                //pp.interactive = pp.constants.interactionLevel.silent;

                                                                                //pp.printerName = "PDFCreator";

                                                                                //pp.printerName = printer;

                                                                                //pp.fileName = "/C/temp/print/outfile.pdf";

                                                                                pp.printerName = printer;

                                                                            //pp.fileName = "outfile.pdf";

                                                                                var status = event.target.print(pp);

                                                                      app.endPriv();

                                                                      return(status);

                                                             

                                                             

                                                             

                                                             

                                                            });