-
-
Notifications
You must be signed in to change notification settings - Fork 640
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
feat: Table cell spans #1736
base: master
Are you sure you want to change the base?
feat: Table cell spans #1736
Conversation
b23d917
to
a893e72
Compare
|
Can you add a test? |
Sure, I just have limited resources and vacation soon, so if someone wants to finish up, I don't mind. |
a893e72
to
dc20c86
Compare
I added a test, but it does not precisely check e.g. the different box properties. |
I have a small problem: the tests now complain, that there's a difference (which is indeed in the renders). I suspect the test renderer interprets this as small gap and therefore outputs the mean as grey? Should we ignore this or solve it another way? |
Yes, that's possible. Seems to be at the intersection of each cell. |
To allow col spans the border must be calculated for each cell and not for the whole width / height of the table any more. So there now exist infinite small fake gaps, which in theory should not be visible, and also aren't in my inspection in the pdf readers, just the pdftocairo does this I think... |
That's fine then. |
I now wonder, if it would make sense to introduce a new widget, like See also: |
3b296a0
to
ace3ac8
Compare
Row span is now also supported via I updated the goldens and saved the diffs here: |
I now used an improved algorithm for rowspanning. There's a special case where the remaining space it not quite optimized, when multiple cells with rowpans overlap and in one row and no cell (without rowspan) with height is given to that row. |
Hello @Gustl22, I tried your changes, I think this is a bug. Codepw.Widget buildSpanCell({
final int columnSpan = 1,
final int rowSpan = 1,
final PdfColor? color,
final double? height,
}) {
return pw.TableCell(
child: pw.Container(
color: color,
height: height,
child: pw.Text('colSpan: $columnSpan, rowSpan: $rowSpan, height: $height'),
),
columnSpan: columnSpan,
rowSpan: rowSpan,
);
}
pdf.addPage(pw.Page(
build: (final pw.Context context) => pw.Table(
children: [
pw.TableRow(
children: [
buildSpanCell(rowSpan: 2, color: PdfColors.red),
buildSpanCell(rowSpan: 2, color: PdfColors.blue),
buildSpanCell(color: PdfColors.green),
],
),
pw.TableRow(
children: [
buildSpanCell(color: PdfColors.green),
],
),
],
border: pw.TableBorder.all(),
),
)); ResultExpectationThe first and second column should have their rows spanned ActualThe first and third column have their rows spanned instead of the second column (notice the border in the second column) |
Add's the col and rowspan feature for tables.
Closes #989, #983, #896, #645, #313, #256, #167