BlogFileMaker

How to generate a PDF and store it in a container field in FileMaker Go

By December 1, 2014 September 5th, 2019 13 Comments
Generating a PDF file and storing it in a container field seems straightforward enough, but if you are using FileMaker Go, you’ll want to keep the following in mind:

When the PDF is created, we need to temporarily store it on the file system, so that it can then be inserted into the container field. However, the Insert PDF script step doesn’t seem to work properly in FileMaker Go when the created PDF is saved to the temporary path: Get(TemporaryPath). The local variable used to specify the file name and path is ignored. Instead the user is prompted to select one of the PDFs stored in the documents folder: Get(DocumentsPath).

Generate PDF container demo
Expand image
By the way, when using FileMaker Go, you can see the PDFs that are in the Get(DocumentsPath) location, if there are any there at all, by selecting “Device” from the left side of the screen. If you have an fmp12 file currently open, you will need to go to your Home view first (tap the icon in the upper-left) and then select “Device” on the left side. We list the PDF files below the FileMaker files, so you may need to scroll down first.

We would like to use the temporary path to store the PDF file, because then it would automatically be deleted once FileMaker closes. But because this doesn’t seem to work properly in FileMaker Go, we must use the Documents path. However, now we need to delete the file after inserted into the container field. We have no “Delete File” script step but do have a workaround. If we run the Export Records script step, making sure to empty out the found set first, the file will be deleted.

Note, in FileMaker Pro, you can also delete a file using the Export Field Contents step if you specify the file name and path but don’t specify a field. But this method doesn’t seem to work in FileMaker Go.

Note: We tested this using FileMaker Pro 13 Advanced with Mac OS X 10.8.5, FileMaker Pro 13 Advanced with Windows Server 2008 R2, and FileMaker Go 13.0.5 with iOS 7.1.2.

Download the demo (zip) file…

Mislav Kos

Mislav Kos

Mislav is a FileMaker developer and a Senior Technical Project Lead at Soliant Consulting.

13 Comments

  • Hi,
    you wrote “If we run the Export Records script step, making sure to empty out the found set first, then the file will be deleted.”

    that is not necessary. You can leave the found set as it is, important is, to have no fields specified in the export records script steps.

    By the way, do you have any better technique to open and show a PDF in the FM Go Browser after exporting?
    I reimport the exported file in a container field, export it again whit the options “open”.
    That is a little bit … but the only way I found out.

    Regards,
    karo

  • Avatar Mislav Kos says:

    Karo, thanks for the tip.

    You asked about viewing the PDF in FM Go after exporting. Take a look at the "Create PDF" script in the accompanying demo file. I use an Insert PDF script step to store the exported PDF file. The file is then displayed in a container field that's been optimized for interactive content.

  • Avatar Steve says:

    Thanks for the tip! I don’t see the download link – can you help?

  • Avatar Mislav Kos says:

    Steve, I'm not sure what happened. It should be there now. Thanks for pointing it out.

  • Avatar Douglas Alder says:

    I wonder if the get(temporary path) issue is not FileMaker’s problem, but rather something set by Apple and their sandboxing policies.

    http://help.filemaker.com/app/answers/detail/a_id/10246

    “Certain actions in FileMaker Go, such as playing a movie that has been inserted into a Container field, require the use of temporary files to be stored and used on your iOS device. By nature, temporary files are not viewable or visible in iOS and are automatically deleted when they are no longer needed.”

  • Mislav Kos Mislav Kos says:

    Douglas ΓÇô Interesting, and it makes sense. Thanks for posting that information.

  • Avatar +Holraven+ says:

    I’ve altered the script to work within my own project, and it works. The annoying thing is that the “delete” step produces the error dialogue “No fields were selected for export.” and I have to click “OK” before the PDF is deleted. This warning is not presented in your example app. How can I supress this error? I use “Export Records [No dialog; “$file”; Unicode (UTF-8)]” just like in your example.

    • Mislav Kos Mislav Kos says:

      When I read your comment, I had assumed that I used a Set Error Capture [On] step in my script, and that maybe you didn’t include that in your script. But upon checking my script, I see that I’m not using that step either. So I’m not sure why the error dialog is shown in one case but not the other. Still, that would be my suggestion – try adding that step immediately before the Export Records step.

  • can you do this with a perform script on server using filemaker 16?

  • Avatar Bert says:

    Thank you for your blog, it explained exactly my problem.

  • Avatar Berto says:

    Hello, many thanks for your great tips always!
    Would it be possible to do the same but for an excel instead of a PDF?
    Thanks

Leave a Reply