Generate a PDF on FileMaker Server

This guide covers how to generate and store a PDF on FileMaker Server, whether running from CWP, Data API, PSOS, or scheduled script.


These sessions cannot run Save Records as PDF directly, nor do they have access to the file system. The solution is to use Perform Script On Server (PSOS) to start a new script session that runs without the limitations of CWP/Data API. After establishing context, follow the instructions below.


If you are creating the PDF in a PSOS session, remember that the normal PSOS rules apply. You need to establish context first as the current layout & found set will not carry over from your client.

The Script

The following steps create a PDF and then insert it into a container:


Set Variable [ $path ; Value: Get ( TemporaryPath ) & "Sample Filename.pdf" ]
Save Records as PDF [ Restore ; With dialog: Off ; "$path" ; Current Record ; Create folders: Off ]
Set Variable [ $urlpath ; "file://" & If ( Get ( SystemPlatform ) = 1 ; "/Volumes" ) & $path ]
Insert from URL [ Select ; With dialog: Off ; Target: $file ; $urlpath ; cURL options: "--FM-return-container-variable" ]
Set Field [ Table::ContainerField ; $file ]
Commit Records/Requests  [ With dialog: Off ]

Notes & Gotchas

Ensure that With Dialog is Off on the Save Records as PDF script step.

Allow Printing must be enabled in the privilege set, otherwise you will get error 3.

All of the regular gotchas of PSOS apply, so you need to pass in whatever information is needed to establish the correct context. Also check your OnFirstWindowOpen script to ensure any unnecessary steps are bypassed when running on the server.

Save the PDF to the temporary folder has important benefits: 1) a new temporary folder is created for every session so there is no risk your data will be exposed to another session running at the same time, 2) the data is destroyed automatically when the session ends.

Insert File is not supported on server scripts so to get the PDF into a container, you need to use Insert From URL. Insert from URL uses a different format for the file path. The calculation in the example above should work on Linux, Mac & Windows servers.

My preference is always to save the result of Insert from URL into a variable, since saving to a field requires that the field be on the current layout. When the result of Insert from URL is binary data, you must include the cURL option --FM-return-container-variable. You can then transfer the result to a field using Set Field without having the layout dependency.

Some resources online claim that the account requires fmapp extended privilege in order to run PSOS. This may be true in version 16 or earlier, but I can confirm that this is not the case in version 17, 18, or 19.

If your output doesn’t look right, check if the required fonts are installed on the server. Some fonts–and some characters–may fail to render on one or more operating systems. Be sure to test your server PDF generation scripts when migrating FMS to a different operating system.

This guide was adapted from the original posted by Jason Wood to the FMBetterForms forum.

4 Replies to “Generate a PDF on FileMaker Server”

  1. Por favor me puede explicar el procedimiento total ?

    Translation: Please can you explain the total procedure to me?

    1. I think everything there is to know about this topic is in the post. What else do you need to know? What are you trying to do and what problem are you having?

  2. Hi Jason, many thanks for this detailed guide! Excellent work. I am stuck at making FMS use the installed font for layout. I installed the font in the server macOS (catalina), but i cant find the reason why it is not picking up. Any settings that I might be overlooking?

    Thanks a lot in advance

    1. Hi Luis, did you install the font at /Library/Fonts/ ?

      If you installed the font in the user’s Fonts folder, I think FMS won’t be able to use that even if the user is logged in.

      Also try restarting the computer.

Leave a Reply

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