Skip to content

Repository files navigation

Form PDF Finisher (form_pdf)

Packagist Software License Brightside

TYPO3 Form Framework finisher that generates custom PDF files from form submissions.

Features

  • Custom PDF Engine: Generates PDFs via the mPDF library by overlaying Fluid HTML templates (containing form markers) onto pre-designed visual PDF background layouts.
  • Flexible Email Attachments: Attaches generated PDFs directly to user and/or receiver emails safely via PSR-14 event listeners (AttachPdfToMailListener), avoiding any overrides to TYPO3 core email finishers.
  • Granular Link Controls: Selectively exposes PDF permalinks (generated_pdf_link) to standard or custom email templates based on targeted finisher checkboxes. This is dynamically injected per email execution using BeforeRenderMailContentEvent to keep the global form state clean.
  • FAL Storage & Headless Ready: Stores generated PDFs permanently in any configured TYPO3 FAL storage (e.g., 1:/form_pdf/). Dynamically resolves complete absolute URLs for these links, ensuring flawless operation across traditional, Headless API, and proxy environments.
  • Secure Confirmation Downloads: Serves direct, downloadable PDF links in frontend confirmation messages with an optional auto-deletion feature for GDPR and data privacy compliance.

Installation

Available in composer mode only:

composer require t3brightside/form-pdf


Configuration & Setup

1. Enable the Site Set

Include the Form PDF Site Set in your site configuration.

2. Create Template Records

Create two backend records in a SysFolder:

  1. PDF Template: High-resolution PDF background layout (e.g., stationary/letterhead).
  2. HTML Template: Fluid-styled template containing form field markers (e.g., {text-1}, {email-1}).

Examples are available in Documentation/example/.

3. Add the PDF Finisher

  1. Open the TYPO3 Form Editor and edit your form definition.
  2. Add finisher and select Form to PDF (PdfFinisher).
  3. Position the PDF finisher before email or confirmation finishers.
  4. Assign your created PDF Template and HTML Template records.
  5. Set finisher options:

Finisher Options

Option Type Default Description
pdfTemplate Integer "" UID of the PDF template record.
htmlTemplate Integer "" UID of the HTML template record.
isPdfAttachedToReceiver Boolean false Attach PDF file to receiver email.
isPdfAttachedToUser Boolean false Attach PDF file to user email.
openPdfNewWindows Boolean false Include download link in confirmation screen.
forceDownload Boolean false Force direct browser download (skip inline preview).
deleteAfterDownload Boolean false Delete temporary file immediately after download link click.
storeOnServer Boolean false Store PDF permanently on server (FAL storage).
isPdfLinkAttachedToReceiver Boolean false Enable PDF permalink in receiver mail.
isPdfLinkAttachedToUser Boolean false Enable PDF permalink in user mail.
storagePath String "" FAL folder identifier (e.g. 1:/form_pdf/ or 2:/formfiles/). Folders are auto-created if missing.
filenamePattern String "{timestamp}-{formIdentifier}.pdf" Stored filename pattern. Supports placeholders.

Filename Placeholders

The filenamePattern option supports the following placeholders:

Placeholder Description
{timestamp} Unix timestamp
{datetime} Current date and time in YmdHi format
{date} Current date in Y-m-d format
{formIdentifier} TYPO3 form identifier
{text-1} Values from any form field identifier

Server Storage & Targeted Email Link Integration

When server storage or link attachments are enabled:

  1. The extension persists the generated PDF into the target FAL folder (storagePath).
  2. The public URL is dynamically resolved to a complete absolute URL (handling origin headers, reverse proxies, and site base configurations).
  3. The ModifyPdfLinkForEmailListener intercepts the BeforeRenderMailContentEvent during email processing:
    • If Enable link to PDF in receiver mail is enabled -> injects generated_pdf_link for receiver emails.
    • If Enable link to PDF in user mail is enabled -> injects generated_pdf_link for user emails.
    • If disabled -> strips generated_pdf_link from FormState and FormDefinition so default <formvh:renderAllFormValues /> templates omit the field.

Security & Privacy Notes

  • storagePath must point to a publicly reachable FAL storage.
  • The extension generates public URLs using File::getPublicUrl(). Token-protected downloads are out of scope.
  • Form submissions may contain sensitive personal data (PII). If so, ensure target folders disable directory listings, prevent search engine indexing, and be password protected if needed.

Garbage Collection

While the extension is designed to instantly clean up temporary files immediately after a PDF is generated or downloaded, edge cases can occur. For example:

  • A user submits the form but closes the browser before clicking the "Download" link.
  • The server experiences a timeout or memory limit crash during PDF generation.
  • Confirmation link files are not set to autodelete but files should not be kept forever.

To prevent your var/transient/ directory from filling up with orphaned files, the extension provides a TYPO3 Symfony Command that acts as a garbage collector.

Setting up the task in the TYPO3 Backend

Go to the TYPO3 Backend and set System > Scheduler > Formpdf > formpdf:clean.

Running via CLI

For deployments or manual execution, you can also trigger the cleanup command directly from your terminal:

# Clean files older than 1 day (default)
vendor/bin/typo3 formpdf:clean

# Clean files older than 30 days
vendor/bin/typo3 formpdf:clean --days=30

# Clean all temporary PDF files immediately
vendor/bin/typo3 formpdf:clean -d 0

Developer Guide

Custom Confirmation Template

The finisher uses Confirmation.html for confirmation views. To override this in your site package:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          finishersDefinition:
            Confirmation:
              options:
                templateName: Confirmation
                templateRootPaths:
                  20: 'EXT:my_sitepackage/Resources/Private/Templates/Form/Finishers/'

Accessing Finisher Variables in Fluid

The finisher registers variables in the FinisherVariableProvider under the Pdf identifier:

<f:if condition="{finisherVariableProvider.Pdf.storedPublicUrl}">
    <f:if condition="{finisherVariableProvider.Pdf.isPdfLinkAttachedToReceiver}">
        <a href="{finisherVariableProvider.Pdf.storedPublicUrl}">Download PDF</a>
    </f:if>
</f:if>

Available provider keys:

{finisherVariableProvider.Pdf.storedPublicUrl}
{finisherVariableProvider.Pdf.storedFilename}
{finisherVariableProvider.Pdf.storedFileUid}
{finisherVariableProvider.Pdf.isPdfLinkAttachedToReceiver}
{finisherVariableProvider.Pdf.isPdfLinkAttachedToUser}

Sources & Links


Contributors


Authors

Tanel Põld

Mykola Orlenko


Maintenance

Maintained by Brightside OÜ – TYPO3 development and web agency specializing in high-performance web applications.

About

TYPO3 extension to write form fields into a pre-existing PDF file

Topics

Resources

Stars

7 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages