4 Replies Latest reply on Feb 26, 2009 5:00 PM by ninja

    Script to make PDF

    sweetcuda

      Title

      Script to make PDF

      Post

      Why creating a script to make a PDF and you want to specify output file, is it possible to have it create the title of the output file from fields in your database?

      I have a receipt that I want to generate a PDF for, and I want its title to be from the fields, purchaser, Charge code, vendor and amount. So the file would be saved as something like

      filewin:/Y:/Requisition forms/Receipts In process/Jason,008,walmart $20.00.pdf

       

      is this do able. Right now it is doing the save file as

      filewin:/Y:/Requisition forms/Receipts In process/Untitled.pdf

      But when I am processing multiple files this wont work because it will save over the top of them.

        • 1. Re: Script to make PDF
          hiatts
            

          absolutely...

           

          all you need to do have a script start on a layout that lists each unique record you want to print...

           

          use a structure like

           

          goto first record

          loop

          goto related record (using a layout specifically for printing an invoice)

          set variable to a unique file identifier such as invoicenumber 

          save as pdf and set filename to previous variable

          goto original layout

          goto next record (exit after last)

          exit loop 

          • 2. Re: Script to make PDF
            sweetcuda
              

            I am a little confused. (New to the database and filemaker). Here is what I have

            I have a layout setup specifically for generating the PDF,

            I have a button that I have setup up to run a script, the script under script manager is like this:

            Go to layout

            Save records as PDF[restore; current record]

            Go to layout

            Exit script

             

            This script runs it brings up the save dialog box. How would I write the script to automatically enter informaiton from 3 or 4 of the fields on the PDF layout into the save as dialog box and save.

             

            Thank you

             

             

             

            • 3. Re: Script to make PDF
              mwc_1
                

              Look at this thread, may help you out.

               

              Emailing out schedules to individual people - help!

              • 4. Re: Script to make PDF
                ninja
                  

                Howdy sweetcuda,

                mwc hit the nail on the head...I'm only chiming in because you mentioned in a previous post that you are a beginner at understanding writing scripts.

                 

                In the script that mwc references, it looks like you'll need only part of it.  The concept is right on, though: (# means side comment, not a functional part of the script)

                 

                # you need to trap your filename and pathname into variables

                    Set Variable [ $Field1ofDesiredFileName ; Field1 ] 

                    Set Variable [ $Field2ofDesiredFileName ; Field2 ]

                    Set Variable [ $Field3ofDesiredFileName ; Field3 ] 

                  

                # trap your filepath into a variable too and add the composite filename(have a global field with your filepath)

                # the field "FilepathforPC" would be the path you're currently using

                      Set Variable [$TargetFile ; FilepathforPC & $Field1ofDesiredFileName & $Field2ofDesiredFileName & $Field3ofDesiredFileName ]

                 

                # then save your record by naming it using the variables from above

                # if you want to do multiple records at once, make sure you have only the records you want to pdf in your found set and replace "Current Record" with "Records being Browsed"

                      Save Record as PDF [ No dialog ; "$TargetFile" , Current record ]

                 

                How does this work for you?