Attaching a PDF File to a Form

Overview

You’ve already installed and activated the Contact Form 7 and PDF Forms Filler for CF7 plugins. You also have a PDF file with a form which you are going to attach to your CF7 form.

Attaching a PDF File

To attach a file, open the CF7 form for editing and click on the PDF Forms Filler tab.

PDF Forms Filler tab in CF7 Editor

Click the Attach a PDF File button. This will bring up WordPress Media Library browser thickbox. Select your already uploaded PDF file or upload one and click Select.

Attaching PDF File from Media Library

Once your PDF is attached, you will see it in the list of attached files. There are two buttons near each file. Clicking the Options button will open a list of options for the file. The Delete button will detach the file.

Attached PDF Files List with Options

Each attached file has a unique attachment [ID] specified in front of the file name. This information can be useful when mapping fields.

This numeric ID corresponds to the identifier of the PDF file in the WordPress’s Media Library. Take care not to delete this file from your Media Library, otherwise your attachment will no longer function.

File Options

Skip when empty

Sometimes it makes sense to ignore the PDF file when none of its fields are filled and no image is embedded into it. In other words, if the user has submitted a form with empty fields, then there is no point in attaching the file to an email or generating a file to download it. If this option is enabled and no information (or blank information) is filled into the PDF file then the file is not attached to any email message, no download link is provided to the user and the PDF is not saved in the wp-content/uploads folder.

Attach to primary email message

If this option is enabled then the filled PDF file will be attached to the CF7’s primary email message.

Attach to secondary email message

If this option is enabled then the filled PDF file will be attached to the CF7’s secondary email message.

Flatten

This option allows the flattening of the PDF form after it is filled. This removes the form fields from the generated PDF file and ensures that the PDF appears static to the user in their PDF viewer.

This parameter is useful if you need to give the user the ability to download a PDF file after submitting the form. A link to download the filled PDF file will be provided alongside the confirmation.

The download link is valid for 1 hour by default. The file will be deleted from the server after the timeout. The timeout can be changed by defining the WPCF7_PDF_FORMS_DOWNLOADS_TIMEOUT_SECONDS constant in your wp-config.php.

Trigger an automatic download of the filled PDF file on a successful form submission response

When this option is enabled, the filled PDF file will automatically begin downloading in the user’s browser immediately after a successful form submission, without requiring the user to click a download link. This provides a seamless experience for users who need immediate access to their filled PDF document. The automatic download occurs only once during the form submission response, and the file is subject to the same timeout settings as the regular download link option.

Filename

Sometimes it is useful to specify a custom filename for your filled PDF file that will be attached to the email messages, downloaded by the user and/or saved in the wp-content/uploads directory. If you leave this field blank, the original attachment filename will be used. Mail-tags can be used as part of the filename. Mail-tag content will be sanitized before being used in the filename.

Save PDF file on the server

In some situations you want to save the filled PDF files on the web server. This option allows you to save your filled PDF files somewhere in the wp-content/uploads directory. Mail-tags can be used as part of the path. You have to make sure to use mail-tags that provide a unique path and/or filename. For example, if you use my-pdfs/[_serial_number] (requires Flamingo) then your filled PDF files will be uploaded to wp-content/uploads/my-pdfs/#####/ (where ##### would be a unique number).

Ensure a unique path and filename combination. If a matching file path exists, a numerical identifier will be appended, potentially causing unexpected outcomes. For example, if the mail download link always points to document.pdf then it will not be pointing to the correct file after the first submission because the actual filename may be document-1.pdf.