Append PDF

Appends PDF pages to the file opened by the Open PDF script step or created by the Create PDF script step.

Options 

  • From is how the PDF file's location is specified:

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

    • Source specifies a PDF file in a container field or variable. When selected, the Source option becomes available.

  • Source file defines a list of one or more paths and filenames for the PDF file when From is File. The script step searches the list and uses the first PDF file it successfully locates. Paths must use one of the image path prefixes. See Creating file paths.

  • Source specifies the container field or variable that stores the PDF file when From is Source.

  • Password is a text expression for the password required to open an encrypted PDF file. If the PDF file is not encrypted, this option is ignored.

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 appends pages from a source PDF file to the currently open PDF file. You must first open or create a PDF file using the Open PDF script step or Create PDF script step before using this script step.

All pages from the source PDF file are appended to the end of the currently open PDF file. The source PDF file isn't modified by this operation.

You can use this script step for combining multiple PDF documents into a single file. For example, to add standard pages (such as cover pages, terms and conditions, or appendices) to generated reports.

Notes 

  • A PDF file must be open before using this script step. If no PDF file is open, this script step returns error code 829 ("No PDF file is open to append to").

  • For encrypted PDF files, if the password is missing or incorrect, this script step returns error code 831 ("Invalid PDF password").

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

Example 1 - Create a report with a cover page

Creates a new PDF file, adds a standard cover page, and saves the complete document.

Copy
Create PDF [ ]
Append PDF [ From: File ; "StandardCoverPage.pdf" ]
Close PDF [ Save to: File ; "Report.pdf" ]

Example 2 - Combine multiple PDF files

Goes to the first record in the Contracts layout, opens an existing PDF file in Global::CombinedPDF, appends the PDF file located in the Contracts::ContractPDF field in each record, then closes and saves the combined PDF file back to the CombinedPDF field.

Copy
Go to Layout [ "Contracts" (Contracts) ; Animation: None ]
Go to Record/Request/Page [ First ]

Open PDF [ From: Source ; Source: Global::CombinedPDF ]
Loop [ Flush: Always ]
    Append PDF [ From: Source ; Source: Contracts::ContractPDF ]
    Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop

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

Example 3 - Append encrypted PDF file with password handling

Creates a PDF file in memory, then prompts the user for the password of the encrypted PDF file to append. If the PDF file is appended successfully, the current record is then appended and the PDF file is closed and saved to a file path. Otherwise, an error message is displayed and the PDF file in memory is discarded by saving it to a local variable, which is cleared when the script ends.

Copy
Set Error Capture [ On ]
Create PDF [ ]

Show Custom Dialog [ "Password for Confidential PDF" ; $inputPassword ]

Append PDF [ From: File ; "ConfidentialAppendix.pdf" ; Password: •••••••• ]
Set Variable [ $errorCode ; Value: Get ( LastError ) ]

If [ $errorCode ≠ 0 ]
    If [ $errorCode = 831 ]
        Show Custom Dialog [ "Authentication Failed" ; "Incorrect password for confidential document." ]
    Else If [ $errorCode = 832 ]
        Show Custom Dialog [ "Access Denied" ; "PDF security settings prevent copying." ]
    Else
        Show Custom Dialog [ "Error" ; "Couldn't append document. Error code: " & $errorCode ]
    End If
    
    Close PDF [ Save to: Target ; Target: $discardPDF ]
    Exit Script [ Text Result: "Failed" ]
End If

Save Records as PDF [ Restore ; Save to: Currently open PDF ; Current record ]

Close PDF [ Save to: File ; "Declassified_Report.pdf" ; Create folders: Off ]