Forms: allow download responses as PDF
Proposed changes:
- Adds PDF response endpoint, Dompdf library and rendering the response with it quite similar to the email
https://github.com/user-attachments/assets/ce3b719f-5251-4d9b-8463-0dd4794ae277
Other information:
- [ ] Have you written new tests for your changes, if applicable?
- [ ] Have you checked the E2E test CI results, and verified that your changes do not break them?
- [ ] Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
- I think you need to update composer deps with:
-
cd projects/plugins/jetpack -
composer update
-
- Then in Forms inbox, pick three dots menu and there's PDF option
- If you get 500 response, you're likely missing dompdf composer dependency somewhere still
- Otherwise you get a basic PDF downloaded, rendered with similar HTML like email
- Check different types of responses
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
- To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the
update/forms-pdfbranch. - To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/forms-pdf
Interested in more tips and information?
- In your local development environment, use the
jetpack rsynccommand to sync your changes to a WoA dev blog. - Read more about our development workflow here: PCYsg-eg0-p2
- Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2
Thank you for your PR!
When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
- :white_check_mark: Include a description of your PR changes.
- :white_check_mark: Add a "[Status]" label (In Progress, Needs Review, ...).
- :white_check_mark: Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
- :white_check_mark: Add testing instructions.
- :white_check_mark: Specify whether this PR includes any changes to data or privacy.
- :white_check_mark: Add changelog entries to affected projects
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation :robot:
Follow this PR Review Process:
- Ensure all required checks appearing at the bottom of this PR are passing.
- Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
- You can use GitHub's Reviewers functionality to request a review.
- When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.
If you have questions about anything, reach out in #jetpack-developers for guidance!
Jetpack plugin:
The Jetpack plugin has different release cadences depending on the platform:
- WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
- WoA releases happen weekly.
- Releases to self-hosted sites happen monthly:
- Scheduled release: January 6, 2026
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.
Code Coverage Summary
Coverage changed in 3 files.
| File | Coverage | Δ% | Δ Uncovered |
|---|---|---|---|
| projects/packages/forms/src/contact-form/class-contact-form-endpoint.php | 799/946 (84.46%) | -1.96% | 24 💔 |
| projects/packages/forms/src/dashboard/inbox/stage/actions.tsx | 0/382 (0.00%) | 0.00% | 19 💔 |
| projects/packages/forms/src/contact-form/class-feedback-field.php | 125/172 (72.67%) | -4.34% | 10 💔 |
1 file is newly checked for coverage.
| File | Coverage |
|---|---|
| projects/packages/forms/src/contact-form/class-response-pdf.php | 0/109 (0.00%) 💔 |
Full summary · PHP report · JS report
If appropriate, add one of these labels to override the failing coverage check: https://github.com/Automattic/jetpack/labels/Covered%20by%20non-unit%20tests https://github.com/Automattic/jetpack/labels/Coverage%20tests%20to%20be%20added%20later https://github.com/Automattic/jetpack/labels/I%20don%27t%20care%20about%20code%20coverage%20for%20this%20PR
https://github.com/dompdf/php-svg-lib/issues/129 may be a blocker here. Hopefully they don't drop php 7.2 support when adding 8.5 support.
dompdf/php-svg-lib/issues/129 may be a blocker here. Hopefully they don't drop php 7.2 support when adding 8.5 support.
@anomiex, can you elaborate on what you meant?
Do you know what this is about:
---
Error: Non-dev composer dependency dompdf/dompdf is not being production-included. Either make it a dev dependency, or add a line like
/vendor/dompdf/dompdf/** production-include
in `.gitattributes`.
---
---
Error: Non-dev composer dependency dompdf/php-font-lib is not being production-included. Either make it a dev dependency, or add a line like
/vendor/dompdf/php-font-lib/** production-include
in `.gitattributes`.
---
---
Error: Non-dev composer dependency dompdf/php-svg-lib is not being production-included. Either make it a dev dependency, or add a line like
/vendor/dompdf/php-svg-lib/** production-include
in `.gitattributes`.
---
---
Error: Non-dev composer dependency masterminds/html5 is not being production-included. Either make it a dev dependency, or add a line like
/vendor/masterminds/html5/** production-include
in `.gitattributes`.
---
---
Error: Non-dev composer dependency sabberworm/php-css-parser is not being production-included. Either make it a dev dependency, or add a line like
/vendor/sabberworm/php-css-parser/** production-include
in `.gitattributes`.
---
As for the not being production-included messages, you'll need to include the relevant paths in here:
https://github.com/Automattic/jetpack/blob/fa1d003e1e9c8609d6720c6bba1ebf60d7d48eb8/projects/packages/forms/.gitattributes
Otherwise, they won't be included as part of the built package.
dompdf/php-svg-lib/issues/129 may be a blocker here. Hopefully they don't drop php 7.2 support when adding 8.5 support.
@anomiex, can you elaborate on what you meant?
The current version of dompdf/php-svg-lib depending on a version of sabberworm/php-css-parser that doesn't support PHP 8.5 is what's causing the fail at https://github.com/Automattic/jetpack/actions/runs/19670703209/job/56338573825?pr=46045#step:10:773
Hopefully when dompdf/php-svg-lib updates that dep, they don't also decide to do "other potential updates" that involve dropping support for PHP 7.2, because WordPress core still supports that version of PHP and Jetpack follows Core in that.
Do you know what this is about:
--- Error: Non-dev composer dependency dompdf/dompdf is not being production-included. Either make it a dev dependency, or add a line like /vendor/dompdf/dompdf/** production-include in `.gitattributes`. --- --- Error: Non-dev composer dependency dompdf/php-font-lib is not being production-included. Either make it a dev dependency, or add a line like /vendor/dompdf/php-font-lib/** production-include in `.gitattributes`. --- --- Error: Non-dev composer dependency dompdf/php-svg-lib is not being production-included. Either make it a dev dependency, or add a line like /vendor/dompdf/php-svg-lib/** production-include in `.gitattributes`. --- --- Error: Non-dev composer dependency masterminds/html5 is not being production-included. Either make it a dev dependency, or add a line like /vendor/masterminds/html5/** production-include in `.gitattributes`. --- --- Error: Non-dev composer dependency sabberworm/php-css-parser is not being production-included. Either make it a dev dependency, or add a line like /vendor/sabberworm/php-css-parser/** production-include in `.gitattributes`. ---
It's telling you that the new vendor packages aren't being included in the built version of Jetpack-the-plugin. It wants you to add the appropriate lines into projects/plugins/jetpack/.gitattributes to tell it to include them.
As for the
not being production-includedmessages, you'll need to include the relevant paths in here: https://github.com/Automattic/jetpack/blob/fa1d003e1e9c8609d6720c6bba1ebf60d7d48eb8/projects/packages/forms/.gitattributes
Wrong file. 😀
Thanks! I added the files to .gitattributes.
We don't use SVGs in the PDF, so I wonder if it would still be safe to include regardless of lacking PHP 8.5 support 🤔
It's also not a critical feature so perfectly fine if we would add PHP version check before loading the feature.
Even then, we'd have to work around the CI installation failure somehow. Ideally without disabling all Jetpack-the-plugin tests for 8.5 like CRM did. 😀 If that's the direction you want to go rather than poking upstream to do the release already, let me know and I'll look into it.