-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support for rowspan and colspan attributes #3002
Comments
The issue at hand involves the lack of support for rowspan and colspan attributes in the react-pdf library, which complicates rendering complex tables in PDFs. To address this, consider the following detailed steps:
react-pdf currently does not natively support rowspan and colspan attributes, leading to incorrect table layouts when these attributes are used. This necessitates manual preprocessing of table structures to achieve the desired layout.
a. Manual Table Structuring:
Manually create a structure without rowspan and colspan by adjusting the data to fit into individual cells appropriately. b. Custom Table Component:
|
Is your feature request related to a problem? Please describe.
The library currently does not support rendering HTML
<table>
elements with rowspan and colspan attributes. This limitation makes it challenging to render complex tables in PDFs where cells need to span multiple rows or columns. For example, when trying to convert the following HTML content into a PDF, the rowspan and colspan attributes are ignored, and the table layout appears incorrect:This limitation requires a lot of manual work to preprocess the table structure and calculate row/column spans, which is time-consuming and error-prone.
Describe the solution you'd like
I would like the library to natively support rowspan and colspan attributes when rendering HTML
<table>
elements. The library should automatically handle these attributes to create tables with the correct layout in the generated PDF, without requiring manual adjustments. For example, the table above should render correctly in the PDF with merged cells where appropriate.Describe alternatives you've considered
Manual Workarounds: Preprocess the HTML content and transform it into a Flexbox-based layout to simulate the rowspan and colspan effects. This approach is complex, especially for dynamic tables with varying structures.
Switch to Other Libraries: Use libraries like wkhtmltopdf that support full HTML rendering, including rowspan and colspan. However, this would require significant changes to the application and would not leverage react-pdf/renderer.
Custom Components: Build custom React components to interpret rowspan and colspan, but this involves significant development effort and does not align with the declarative nature of
react-pdf/renderer
.Additional context
We would be more than happy to donate for this feature to be implemented :)
The text was updated successfully, but these errors were encountered: