9 Replies Latest reply on Aug 29, 2012 6:01 AM by kreisel

    Opening a PDF outside of FileMaker

    kreisel

      My FM database creates a client invoice in the form of a PDF. The file name is based on the client ID and the event ID like this:

       

      Events::_fk.ClientID & "_" & Events::__pk.EventID & ".pdf"

       

      Example: 0002_0003.pdf

       

      I want a button that will open this file outside of FM in either Adobe Reader or Mac's Preview.

       

      I've searched the forum and other sites and have determined I probably need both FM Script and Applescript, but am having trouble with the syntax of quotes and passing the above vairable to the Applescript. The button should use the current record to open the file.

       

      The files will always be located in a subfolder from the database file. This folder is called "Contracts".

       

      Thanks in advance!

        • 1. Re: Opening a PDF outside of FileMaker
          ariley

          FileMaker cannot control what happens outside of FileMaker. 

           

          You can, however use other methods, such as AppleScript, shell script or VB script on Windows.

           

          So, if you're on Apple, your FileMaker script can start an AppleScript and tell Preview to open the aforementioned file. 

           

          Regards,

           

          Agnes Riley

          FileMaker 10 and 11 Certified Developer

           

          http://www.zerobluetech.com

          C 917 660-7221

          T 201-293-5828

           

          Member, FileMaker Business Alliance

          Member, FileMaker Technical Network

          • 2. Re: Opening a PDF outside of FileMaker
            deninger

            I could be missing something in your question. Is the PDF in a container at this point? If so, a single script step Export Field Contents using the Automatically Open FIle after saving check box would do the trick.

             

            If it is not in a field, how exactly is the PDF being generated?

            1 of 1 people found this helpful
            • 3. Re: Opening a PDF outside of FileMaker
              ariley

              Right, I forgot about that tiny checkbox.  

               

              But generally, my method applies when all else fails. 

               

              Regards,

               

              Agnes Riley

              FileMaker 10 and 11 Certified Developer

               

              http://www.zerobluetech.com

              C 917 660-7221

              T 201-293-5828

               

              Member, FileMaker Business Alliance

              Member, FileMaker Technical Network

              • 4. Re: Opening a PDF outside of FileMaker
                beverly

                Rob, what version of FM? If you have the containers as "Interactive content" (through the Inspector in FM12), then you should see some icons as you hover over the PDF in the container. I can "Open PDF in Preview" by clicking on of the appropriate icon:

                fm12_interactive_content.jpg

                Does that help?

                Beverly

                1 of 1 people found this helpful
                • 5. Re: Opening a PDF outside of FileMaker
                  kreisel

                  These sounds like good ideas. I'll play around with it a bit and let you know. I do have FM12 so I can use interactive containers.

                   

                  -rob

                  • 6. Re: Opening a PDF outside of FileMaker
                    TomHays

                    Insert the file into a container field by reference. This must be stored as a referenced file so that you have the PDF icon being displayed.

                     

                    Create a button that has the script behavior of

                    Go to Field [Select/perform; MyTable::myContainer]

                     

                    This will do the same thing as double-clicking on the PDF file icon. It will ask your operating system to open the file in the standard PDF viewer.

                     

                    In your case you already have the full path to the external PDF file. You just need a calculated field that returns a Container result.

                    Assign it a value like "file:myFile.pdf" or in your case

                    "file:Contracts/" & Events::_fk.ClientID  & "_" & Events::__pk.EventID & ".pdf"

                     

                    -Tom

                    • 7. Re: Opening a PDF outside of FileMaker
                      kreisel

                      Tom,

                       

                      This is exactly the solution I'm looking for. Works perfectly. One question though. After I got it all working, I decided to delete the contrainer field from the layout (not of course from the table), since I have a script to save the file to the container field, and I have the button you described to open the file. Then it stopped working. Maybe this should be obvious, but why does the field have to be displayed on the layout for the scripts to work?

                       

                      Rob

                      • 8. Re: Opening a PDF outside of FileMaker
                        TomHays

                        The field needs to be on the layout because that's a limitation to the Go To Field[] script step.

                         

                        That script step is one of the set of navigational script steps that navigate to places on the current layout.

                         

                        Go to Field[]

                        Go to Next Field[]

                        Go to Previous Field[]

                        Go to Object[]

                        Go to Portal Row[]

                         

                        They automate the user's interaction with the objects on the current layout.

                         

                        -Tom

                        • 9. Re: Opening a PDF outside of FileMaker
                          kreisel

                          Makes sense. Thanks for your help. Working well now.