Add readonly attribute support for input and textarea #832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for the standard HTML
readonlyattribute 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
html2pdfto recognize thereadonlyattribute and apply the corresponding read-only flag to the PDF form fields:<textarea>: Modified the_tag_open_TEXTAREAmethod insrc/Html2Pdf.php(around line 6054) to detect thereadonlyattribute and set the field properties accordingly.<input>: Modified the_tag_open_INPUTmethod insrc/Html2Pdf.php(around line 6163) to detect thereadonlyattribute and set the field properties for applicable input types.References:
<textarea>readonlyattribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#readonly<input>readonlyattribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonlyNote:
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.