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

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

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.

Demo File

13 thoughts on “How to generate a PDF and store it in a container field in FileMaker Go”

  1. 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

  2. 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.

  3. 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.”

  4. 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.

    1. 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.

  5. 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

    1. I don’t recall from personal experience. A quick look at the help pages indicates that the Export Records can be used to create Excel files in Go (https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Fexport-records.html%23), so it seems that this might be possible to do.

      If that doesn’t work, you could also create the Excel file using a web viewer and a JavaScript library like http://sheetjs.com/, but this would be much more work to implement.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top