Close PDF

Closes and saves the open PDF file to a file path, variable, or container field.

Options 

  • Save to is where to save the PDF file:

    • File specifies a PDF file path. When selected, the Output file option becomes available.

    • Target specifies a container field or variable. When selected, the Target option becomes available.

Additional options available when Save to is File:

  • Output file defines a list of one or more paths and filenames for the PDF file. The script step searches the list and saves to the first path it can successfully write to. Paths must use one of the file path prefixes. See Creating file paths.

    You can also select:

    • Automatically open file to have the output file open with the default application

    • Create email with file as attachment to display a new email message in the user's default email application, with the output file attached

    If FileMaker Pro runs a script that does not specify an absolute path, and the database file containing the script is hosted, the path is assumed to be the current user's Documents folder.

  • Create folders specifies whether to create new folders that you specify in the output file path.

Additional options available when Save to is Target:

  • Target specifies the container field or variable that the PDF file is saved to.

  • Filename is a text expression that specifies the filename to use. This filename is stored with the PDF data and appears when the PDF file is exported or referenced. If not specified, a default filename is used.

Compatibility 

Product Supported
FileMaker Pro Yes
FileMaker Go Yes
FileMaker WebDirect Partial
FileMaker Server Yes
FileMaker Cloud Yes
FileMaker Data API Yes
Custom Web Publishing Yes

Originated in version 

26.0

Description 

This script step closes the currently open PDF file and saves it to the specified destination. This is the final step in any PDF workflow that uses the Open PDF script step or Create PDF script step.

After this script step completes successfully, no PDF file remains open, and you can create or open another PDF file if needed.

Notes 

  • A PDF file must be open before using this script step. If no PDF file is open, this script step returns error code 5 ("Command is unavailable").

  • This script step must be used to complete any PDF workflow. Failing to close an open PDF file prevents opening or creating additional PDF files.

  • If the specified output location cannot be written to (for example, due to permissions or disk space), the script step returns an appropriate error code but the PDF file remains open. If a file with the specified file path already exists, this script step overwrites the existing file without returning an error.

  • The open PDF file and any unsaved changes are lost if either of the following happens:

    • The current FileMaker client session ends

    • The FileMaker Pro file whose script opened the PDF file closes without closing the open PDF file

  • In FileMaker WebDirect, the Save to: File option isn't supported.

Example 1 - Save PDF to file

Creates a PDF file, adds pages for the current records, and saves it to Report.pdf in the user's Documents folder.

Copy
Create PDF [ ]

Save Records as PDF [ Restore ; Save to: Currently open PDF ; Records being browsed ]

Set Variable [ $filePath ; Value: Get ( DocumentsPath ) & "Report.pdf" ]

Close PDF [ Save to: File ; $filePath ; Create folders: On ]

Example 2 - Save PDF file to container field

Creates a PDF report, stores it directly in a container field, and sets metadata fields for when it was generated and its type.

Copy
Create PDF [ ]

Append PDF [ From: Source ; Source: Global::CoverPage ]

Go to Layout [ "Monthly Report" (Reports) ]
Save Records as PDF [ Restore ; Save to: Currently open PDF ; Records being browsed ]

Close PDF [ Save to: Target ; Target: Global::GeneratedPDF ]

Set Field [ Global::GeneratedDate ; Get ( CurrentTimestamp ) ]
Set Field [ Global::ReportType ; "Monthly Summary" ]