4 Replies Latest reply on Mar 18, 2010 9:45 AM by frootjooce

    opening a specific page in a pdf

    frootjooce Level 1

      Hi,

       

      I am working on a cross platform project.  I can open a specific page in a pdf in windows with the following script using buddy but am so far unable to get this to work on the mac.

       

      on mouseUp me
        global gMoviePathName
        cursor 0
        theApp = baShortFileName(baFindApp("pdf"))
        thePath = baShortFileName(gMoviePathName &"resource\myfolder\myfile.pdf")
        theAppString = theApp & " /A page=1 " & thePath
        theResult = baRunProgram(theAppString, "Normal", FALSE)
        
      end

       

      But even leaving out the attempt to locate the individual page I can't get this code to work.

       

      on mouseUp me
        global gMoviePathName
        cursor 0
       
        theApp = baShortFileName(baFindApp(".pdf"))
        member("text1").text = theApp
       
        thePath = baShortFileName(gMoviePathName &"resource:myFolder:myFile.pdf")
        member("text2").text = thePath
       
        theAppString = theApp & thePath
        member("text3").text = theAppString
       
         theResult = baRunProgram(theAppString "Normal", FALSE)
        member("text4").text = theResult
       
      end 

       

      The trace fields seem to return the pathnames ok but the final path returns 0 [error]

       

      Can anyone help?

        • 1. Re: opening a specific page in a pdf
          Sean_Wilson Adobe Community Professional

          Don't you need a SPACE between theApp and thePath? That is

          theAppString = theApp & thePath

          should be

          theAppString = theApp && thePath
          • 2. Re: opening a specific page in a pdf
            frootjooce Level 1

            Thanks Sean, a good point but doesn't solve it.

             

            Here is the output I am getting from the final variable. I changed the file to a jpg just to check if the problem was related to acrobat itself.

             

            Final line of code:

            theAppString = theApp && thePath

             

            returns:      MyDisc:Applications:Preview.app: myDisc:myFolder1:myFolder2:myFolder3:myFolder4:myFile.jpg

             

            but

             

            theResult = baRunProgram(theAppString "Normal", FALSE

             

            returns a error code 0

            • 3. Re: opening a specific page in a pdf
              Mike Blaustein Level 4

              One problem that I see is that the executable file should not have a colon after it:

               

              MyDisc:Applications:Preview.app: myDisc:myFolder1:myFolder2:myFolder3:myFolder4:myFile.jpg

               

              should be

               

              MyDisc:Applications:Preview.app myDisc:myFolder1:myFolder2:myFolder3:myFolder4:myFile.jpg

               

               

              And another is that it looks like you have missed some punctuation in the baRunProgram command (possibly a copying error)

               

              theResult = baRunProgram(theAppString "Normal", FALSE

               

              should be

               

              theResult = baRunProgram(theAppString, "Normal", FALSE)

               

               

              One last item is that the Preview.app program probably does not accept the same command line switches as acrobat reader, therefore you are unlikely to make it open to the page you want.  You would probably need to make sure that the Mac has acrobat reader on it, and use it to open the file.

              • 4. Re: opening a specific page in a pdf
                frootjooce Level 1

                Thanks Mike,

                 

                I thought about the colon after the app too but this is the path provided by buddy.  I tried hard coding it without the colon - makes no difference. Yes the missing comma in the arguments was a typo

                 

                Think I will resort to baOpenFile which seems to work and just split up all the pdfs.

                 

                I'll get there quicker in the end.