-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Added support for Select fields as combo boxes #2000
Conversation
cfaaf69
to
13a3e77
Compare
I don't know if overriding the select box in |
Hi! Thank you for this pull request. Some elements you insert in the PDF are hardcoded values (you probably found in your PDF), but they should be real data instead (or even not set at all): Moreover, could you please provide a HTML sample showing the result? I can’t get an example that’s working for me. |
13a3e77
to
c5c7b39
Compare
Hi, thank you for reviewing and answering my PR 🙏 from weasyprint import HTML
# Create a HTML object from a string with a multiple select field
html = HTML(string='''
<html>
<body>
<label for="select-sample">Select Sample</label>
<select name="sample">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5" selected>Five</option>
</select>
<label for="textarea-sample">Textarea Sample</label>
<textarea name="textarea-sample"></textarea>
<label for="input-sample">Input Sample</label>
<input name="input-sample" value="Sample">
</body>
</html>''')
# Write the PDF
html.write_pdf('example.pdf', stylesheets=html._ua_stylesheets(True)) I'll attach the |
Actually, DocumentViewer can render a List Box, but the multiselect won't work on it. |
21d25bd
to
dc037d1
Compare
Hello @liZe, have you had time to check this PR? Is there anything that you want me to change? |
I’ll add a comment as soon as I find the time to review it! I’m currently working on other issues. |
weasyprint/layout/block.py
Outdated
@@ -833,6 +833,29 @@ def block_container_layout(context, box, bottom_space, skip_stack, | |||
if next_page['page'] is None: | |||
next_page['page'] = new_box.page_values()[1] | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should be CSS instead (in html5_ua.css
). Inputs in browsers have been (and still are?) a mess to style because of awful non-CSS hacks, let’s not do like them! 😄
I’ll clean a couple of little things (including the styling hack) and let you review before merging. I’ll also manually test in different PDF readers. (And don’t worry about tests failing with 3.7!) |
I've decoded two PDFs, one with the combo box and another blank and extracted the binary info necessary to render it and applied to the `anchors.add_inputs` function.
dc037d1
to
2a7ced5
Compare
@VagnerNico Feedback is welcome! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to add; thanks for fixing my wrong assumptions.
Also, I've tested several HTML where I'm using the lib, and everything works fine.
I've decoded two PDFs, one with the combo box and another blank and extracted the binary info necessary to render it and applied to the
anchors.add_inputs
function.