1 2 Previous Next 16 Replies Latest reply on May 15, 2012 5:11 PM by cortical

    save as PDF script problems

    wesfolio

      Using Filemaker pro advanced.

      I have an invoice database.

      I want to make a script that will save the invoice as a pdf and name it with the invoice number & company code.

      I've achieved that, but I can only save it to my desktop using the (DesktopPath) code.

      How do I make it save the pdf to a specific folder on my mac?

       

      current script:

       

      Set Variable [$filePath; Value:Get ( DesktopPath ) & INVOICES::invoiceNumber &" " & Clients table::CoCode & ".pdf"]

       

      Save Records as PDF [Restore; No dialog; "$filePath"; Current record]

        • 1. Re: save as PDF script problems
          Stephen Huston

          If this is an unhosted solution, you could place a folder in the same folder with your solution file and use a realtive file path to that folder for saving on your local machine.

           

          If, however, the solution is hosted,  the clients' desktop path is what's most reliable for all users.

           

          There are some plug-ins which allow both folder creation and greater filepath control, but I do not have direct experience with the current versions of those plug-ins.

          • 2. Re: save as PDF script problems
            wesfolio

            thanks for the reply.

            The database is unhosted, but I want to be able to save the pdfs in a folder with my business files. They are not located on the desktop. They are located within my user folder which is preferred.

            Is there any way to make the solution results in a specific location?

            • 3. Re: save as PDF script problems
              Stephen Huston

              You can script the location and path on the local machine relative to the current FileMaker file by using both a $variable to name the file ($PDFname) however you want it named, and setting the file path in the Specify File option of the script step:

              • file:TopFolder/PDFs/$PDFname

              The TopFolder (whatever you name it is OK) needs to be In the same folder with your open FM file for this sample filepath to work, and the PDFs folder must exist. FMPro won't create  folders  itself, but this type of relative file path will work with existing folders.

              • 4. Re: save as PDF script problems
                wesfolio

                I'm not sure I understand, "setting the file path in the Specify File option of the script step".

                I've tried adding text to my current script with "file:" followed by the folder path separated by "/"s.

                I got an error message. I'm not sure if it's just a syntax error. I hate the idea of bothering you with nitty gritty detail.

                If you  know if some good online sources for this particular subject, I'd be grateful. I'd probably need something that shows example code written in perfect syntax. Thanks for putting up with my noviceness.

                • 5. Re: save as PDF script problems
                  sporobolus

                  on 2012-05-10 12:03 wesfolio wrote

                  I'm not sure I understand, "setting the file path in the Specify File option of the script step".

                  I've tried adding text to my current script with "file:" followed by the folder path separated by "/"s.

                  I got an error message. I'm not sure if it's just a syntax error. I hate the idea of bothering you with nitty gritty detail.

                   

                  you need to use the exact syntax for FileMaker paths, which differs from paths

                  you'd use in other contexts; if this solution always runs on the same machine,

                  it's pretty safe to use a specific path

                   

                  for example if you are on a Mac, your hard disk is named "drive", and your

                  username is "me", this would specify a pdf file in the "business" folder within

                  your documents folder:

                   

                  /drive/Users/me/Documents/business/invoice.pdf

                   

                  as you can see, if this needs to run on multiple machines, you can't be so

                  specific, so that's why something like this would be favored:

                   

                     Get(DocumentsPath) & "business/invoice.pdf"
                  

                   

                  (and this will fail if the business folder doesn't pre-exist)

                   

                   

                  If you  know if some good online sources for this particular subject, I'd be grateful.

                   

                  this is a fairly good resource:

                   

                  <http://www.filemaker.com/11help/html/create_db.8.32.html

                  • 6. Re: save as PDF script problems
                    wesfolio

                    Thanks so much, Steve.

                     

                    I plan to make this work on my computer only. That said, where would you recommend I input my version of the code, "/drive/Users/me/Documents/business/invoice.pdf" in my current script? Would it be in the "Set Variable" part, or the "Save Records as PDF" part?

                    • 7. Re: save as PDF script problems
                      sporobolus

                      on 2012-05-10 13:21 wesfolio wrote

                       

                      I plan to make this work on my computer only. That said, where would you recommend I input my version of the code, "/drive/Users/me/Documents/business/invoice.pdf" in my current script? Would it be in the "Set Variable" part, or the "Save Records as PDF" part?

                       

                      the way your script is set up now, it could be in the Set Variable, but your

                      situation is simple enough that you could delete the Set Variable step and put

                      the path directly into the Save Records as PDF step

                      • 8. Re: save as PDF script problems
                        wesfolio

                        Yes, but the Set Variable part is where I do the renaming of the pdf file (with invoice # and company code)

                        Are you saying I can do all of that in the Save Records as PDF step, too?

                        • 9. Re: save as PDF script problems
                          sporobolus

                          on 2012-05-10 14:49 wesfolio wrote

                          Yes, but the Set Variable part is where I do the renaming of the pdf file (with invoice # and company code)

                          Are you saying I can do all of that in the Save Records as PDF step, too?

                           

                          no, forgot about the renaming — do it in Set Variable

                          • 10. Re: save as PDF script problems
                            keywords

                            For what it's worth, I would suggest using the Let( ) function in your Set Variable calc to break down the variable into its components. eg.:

                             

                            Let( [

                                mainpath = "/drive/Users/me/Documents/business/" ;

                                name = INVOICES::invoiceNumber &" " & Clients table::CoCode ;

                                extension =  ".pdf" ] ;

                            mainpath & name & extension )

                             

                            This makes the syntax clearer and simplifies editing either the path or the document name as separate elements. It also facilitates adding a date or timestamp into the document name simply by adding an extra variable into the equation.

                             

                            Cheers!

                            • 11. Re: save as PDF script problems
                              wesfolio

                              Hi Keywords. Thanks for the post.

                              I put in my path info into the script you sent. I double checked the path to make sure it is correct. It seems like it should work, but I get an error message,

                              ""132070 NYT.pdf" could not be created on this disk. Use a different name, make more room on the disk, unlock it or use a different disk."

                               

                              Here's what I used:

                               

                              Set Variable [$filePath; Value:

                              Let( [mainpath = "G5 Hard Drive/Users/wesleybedrosian/Dropbox/WB Studio/SENT INVOICES/" ;

                              name = INVOICES::invoiceNumber &" " & Clients table::CoCode ;

                              extension =  ".pdf" ]

                              ;mainpath & name & extension )

                               

                              Save Records as PDF [Restore; No dialog; ""$filePath"; Current record]

                              • 12. Re: save as PDF script problems
                                Stephen Huston

                                Puta back-slash before the drive name, as in the example, and verify the exact names of all directories and disk name as exact matches to your Let functions.

                                • 13. Re: save as PDF script problems
                                  wesfolio

                                  success!!

                                  My problems were all due to a missing back-slash.

                                   

                                  Thanks so much. What a fantastic forum.

                                  • 14. Re: save as PDF script problems
                                    Lemmtech

                                    put the proper platform prefix in the path string (eg: filemac://) The syntax for the mainpath element of your statement is not formed properly at the begining and that is your problem. that error almost always means a  path string error such that the OS doesn't know how  to find the directory you want to try and write to. It needs to start like this:

                                     

                                    filemac:/G5 Hard Drive/Users/etc...

                                     

                                    See below for path examples from FM help file.

                                     

                                     

                                    Type of path

                                    Description

                                    Format

                                    Relative

                                    The path to a target file specified from the current database’s location. If the current database is opened remotely, the path starts from the local FileMaker Pro directory

                                    file:directoryName/fileName

                                    filemac:directoryName/

                                    filewin:../fileName

                                    Full local or remote(Mac OS)

                                    The absolute path to a target file or folder, either local or on a remote volume, beginning at the top level of the file system

                                    filemac:/volumeName/directoryName/fileName

                                    filemac:/volumeName/directoryName/

                                    Full local (Windows)

                                    The absolute path to a target file or folder in Windows, beginning at the top level of the file system

                                    filewin:/driveletter:/directoryName/fileName

                                    filewin:/driveletter:/directoryName/

                                    Full remote (Windows)

                                    The absolute path to a target file or folder on a Windows volume shared using Windows file sharing

                                    filewin://computerName/shareName/directoryName/fileName

                                    filewin://computerName/shareName/directoryName/

                                    FileMaker Network

                                    The network path to a shared FileMaker Pro file

                                    fmnet:/hostIPaddress/fileName

                                    1 2 Previous Next