-
-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for editable forms lacks support for radio buttons #1831
Comments
@liZe - Is the constraint that only one option in a radio button group is selected that complicates including it in the editable (fillable) forms? Is there anywhere that talks more about what's missing? I was looking at #1796, and you'd outline an approach to adding PDF forms when responding for adding support. Looking at Is there any workaround? There's older response over here that points to a "tips & tricks" docs page that is to the previous host of the docs. I originally thought you might be able to render an underlying checkbox, but style it to appear as a radio button (and you'd lose the constraint for having only one selected). Would looking at the pydyf approach to creating the PDF form tag help if I was brave enough to take a shot at a pull request? Thanks for all the time you've put into this project & other Kozea projects |
The problem is to create these groups: we must find radio buttons that have the same name (shouldn’t be too hard) in the same form (that’s the hard part, because we don’t store this information). Rendering these inputs is the easy part (after spending some time reading the PDF specification, of course 😄). The clean solution would be to gather forms and their inputs, instead of just gathering a list of inputs, in
Gathering forms would also be useful to create PDF forms that send data to servers. But let’s keep that for another issue! |
Thank you for this detailed reply. I'll see if I can understand a bit better and maybe I'll have a follow-up question or two.
I noticed in your profile the mention of being a "specification reader" 😉 |
@liZe - when I was looking at another Python pdf library, I believe they stated the PDF 1.7 spec is the latest. Before I look closer, I wanted to make sure I'm in the right "neighborhood": This is falls in the Acrobat SDK area, correct? And this is the document to look at? https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf 📝 the reason I asked if because the previous hyperlink used to refer to PDF 1.7 spec, https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf, is now resolving to this page: https://opensource.adobe.com/dc-acrobat-sdk-docs/ (cool that there is now an opensource.adobe.com subdomain ✨) |
There’s actually PDF 2 (now available for free), but 1.7 is totally OK and easily available online, so you can use it.
You don’t have to use any of Adobe code, or to follow any of their API.
Yes. Section 12.7 is about forms, and section 12.7.4.2.4 is about radio buttons. You’ll see that’s it’s actually a subtype of buttons, really close to checkboxes (that are already implemented in WeasyPrint). |
Sorry @liZe - I worded this confusingly. I mainly wanted to confirm that I was reading that the right specification. I did find the section on Field Types and Radio Buttons in PDF 1.7. It seems like there is some valuable effort to get to the point where radio buttons could be rendered. So I'm going to try to address the first 4 bullets mentioned (regarding gather as form(s) that are keyed from form => input(s)) over here and I'll pull request them back to that forked repository in case anyone is curious to look at it: |
@zopyx - a note about the sample provided here, the weasyprint.pdf is no longer available at the provided link: |
@liZe - given what you know the source code, focusing these 2 bullets:
Do you have any thoughts about how you'd handle encountering a |
If it’s not in a form, then it’s global and will be put with other global inputs. If we store forms with this structure:
then we can use |
That makes sense. I wasn't sure of the implications. Thanks @liZe 🙇 I have a PR nearing draft for "gathering forms" so that they're tracked. It does not address anything with the radio button groups yet. I thought if I sliced it a bit thinner it might help me tune up my Python (I haven't written Python in 3-5 years). |
I might be getting ahead of myself. But do see the "gathering" of inputs within their containing form (and/or global form) as causing any problems with the order they appear within a page of a document? I can try to look closer at the pytests maybe for an answer there. |
I’m not sure to understand your problem, but I don’t see why the order could be a problem. |
I'll see if I can get a little example together. But if we're putting the inputs into a forms dictionary, we lose the source order when process the dictionary by its' keys. |
I’m not sure that it’s a problem:
That would help! |
I forgot that Python will get your the order that keys were "put" into the dictionary! I expected that when we did a 😮💨 🤦 Sorry for the confusion. |
👋 excited to see the conversation here and possible solution! It looks like this thread may have gone a bit stale - @alenards I'm curious if you're still looking into this, otherwise I may take a look as it'd be really nice to have for a project I'm working on. |
Hi @okkays / Kevin, I haven't been able to spend enough time here. I agree that it is a nice project, and I know that it would be highly valuable. I had my super draft work in branches on the fork I made: https://github.com/alenards/WeasyPrint/branches I haven't touched it for 9 months, but I was using the feedback from here to "gathering together" the form inputs, and then trying to get all the radio button inputs in their group: https://github.com/alenards/WeasyPrint/commits/issue-1831-forms-gathering/ I thought I'd get them "tracked", but I didn't know enough about the encode in the rendering (and trying to wrap my head around the spec, how "children" - aka kids - needed to be written out). I'm on a US timezone, seems from your profile you are too. I've been up to "pair & ponder" on this. I just know I can't try to tackle it as a primary contributor right now 😢 |
Thanks for the quick response and sharing your work so far! I'll take a look through what you have and spend a bit of time in the code to try and size this up 😄 |
What I have committed is very much "sketches"; I don't think it would make it through any level of code review. And, it might help. I think the instructions for getting test suites running locally are up-to-date now 🤞 (or hope they are). |
#2143 is up for this following the outline from #1831 (comment) 😄 |
WHOA! |
See
https://print-css.rocks/lesson/lesson-forms
https://print-css.rocks/lesson/lesson-forms/download/weasyprint.pdf
No offense but your implementation is only a partial implementation for editable forms (compared to other tools) since
the support for radio buttons is missing (and the rendering is broken).
The text was updated successfully, but these errors were encountered: