4 Replies Latest reply on Nov 25, 2012 3:06 AM by peagar

    How to open PDF files from a script


      Mac platform, V 11


      I wish to view PDF documents stored on my computer by accessing from a field in a FileMaker database.


      To do so I wish to write a script that will use a reference stored in a field in each record.


      Suppose the field is called "PDF reference": and has the values "target1.pdf", "target2.pdf", etc


      The following script will open the document "target.pdf"


      Send Event ["Adobe Reader"; "aevt"; "odoc"; "target.pdf"]


      but what I need is a script that will open the PDF document named in each field (eg target1.pdf, target2.pdf etc) , something like:


      Send Event ["Adobe Reader"; "aevt"; "odoc"; <PDF reference>]


      I am sure it can be done, but I cannot find the exact syntax required. Can anyone help please?

        • 1. Re: How to open PDF files from a script

          I think you are creating a complication for something which can happen natively using an "open URL" script step.


          If you are opeing files on the same computer as the database you can calculate a "file:/..." path to the file by filename and if you were to host the files on a web server (even locally) you could access the files by using "http://...".


          You might also consider that you do not have to leave FileMaker if you display these PDF's in a Web Viewer. If there is only one PDF per record, just going to the record could load the relevant PDF.


          You do not have to specify a PDF reader as whichever is the default on the machine will be used.


          - Lyndsay

          1 of 1 people found this helpful
          • 2. Re: How to open PDF files from a script

            Thank you for the reply.  I had not thought of open URL.


            I have puzzled out an alternative, the script going something like this:


            Set Variable [$pdf; Value filename::fieldname]

            Send Event ["Adobe Reader"; "aevt"; "odoc"; "$pdf"]


            I just couldn't find anything in my various Manuals, or the Help file.  Its just a bit frustrating when you know something can be done, but can't work out how!




            • 3. Re: How to open PDF files from a script

              That should actually work... providing the path to the filename is correct.

              Is that the last step in the script?


              - Lyndsay

              • 4. Re: How to open PDF files from a script

                The whole script looks like this:


                If [Right (Getty::Getty ac pdf;3) = "pdf"]

                Set Variable [$pdf; Value:Getty::Getty ac pdf]

                Send Event ["Adobe Reader"; "aevt"; "odoc"; "$pdf"]


                Perform Script ['Return to 1"]

                End if


                It runs from a button and will show the PDF in Adobe Reader if there is a reference, otherwise it just leaves you were you are.


                Thanks for the interest.