Skip to content

Conversation

@kkevinchoo
Copy link
Contributor

@kkevinchoo kkevinchoo commented Apr 15, 2025

This pull request introduces support for the standard HTML readonly attribute on <input> and <textarea> form fields within the generated PDF. Currently, this attribute is ignored, preventing the creation of read-only form fields in the PDF output even when specified in the source HTML.

Enhancements:

The changes enable html2pdf to recognize the readonly attribute and apply the corresponding read-only flag to the PDF form fields:

  • <textarea>: Modified the _tag_open_TEXTAREA method in src/Html2Pdf.php (around line 6054) to detect the readonly attribute and set the field properties accordingly.
  • <input>: Modified the _tag_open_INPUT method in src/Html2Pdf.php (around line 6163) to detect the readonly attribute and set the field properties for applicable input types.

References:

Note:

I understand the importance of maintaining stability in the library's codebase. However, I encountered this limitation myself and wanted to share this solution, both for potential integration and to help others who might be facing the same issue with needing read-only fields in their generated PDFs.

Thank you for considering this contribution.

@spipu spipu merged commit 158fd7b into spipu:master Apr 25, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants