-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Rowspanned TD element lost on page break #1388
Comments
I'm fairly certain there's an existing issue for this ... but I couldn't find it in a quick search. |
Right! I have encountered some similar issues, but no solution. |
is this still unsolved? i am facing same issue |
yes still broken... switched to wkhtlmpdf now. |
Minimum example to test the problem (A4, landscape)
Any active rowspan is not remembered on page breaks. |
having the same problem here!
|
Also here. I read that its a known issue that table row has to be on one page, but to not carry a rowspan to the next page is a severe bug. I did a debug query and it seems that the table structure (tablemap) is intact, its only that the rowspan is not remembered and cells are dropped in the wrong column. I think it would be possible to remember the rowspan with an temporary array and check this after the pagebreak to "skip" rowspanned cells on the next page. Who can help on that? |
I confirm this issue is still present in last 1.0.2 version |
Thanks Brian - yes this issue looks like my problem #2676. Have not seen this issue by using the searchengine, sorry for that. Just let me know By the way, the start post of this issue makes me a little bit worried if i have a look on the date. |
I can't promise a quick solution though I have been thinking about the problem a bit recently. Other more urgent issues have come up recently, however, so it'll have to wait until those are resolved for me to look at the problem. Though, of course, anyone is welcome to try to solve the issue so maybe a kind soul will submit a PR. |
I just wanted to know which classes would be affected by this or where is the doing for it contained? I also have a lot to do at the moment, but maybe one or the other time will come up. |
The evaluation for the rowspan and colspan looks correct. Apparently there is somewhere the worm in Cellmap.php (line 575 to 589) but I'm not sure yet - guess i'm wrong.
|
I believe the issue is that when a row is paged the map of cells associated with the row is reset, but the row-spanned cell is not added back when building the cell map on the following page because the logic only looks at direct children of the elements being rendered. |
how do you handle the output during creation. debugging is somewhat difficult that way. |
|
How did you solve it |
I suppose this doesn't have any chance of getting fixed any time soon, right? |
I don't really have a sense of what this will take to fix but I'll take a look. Also, what is your definition of "soon" because releases are sparse. |
Nice to hear, it would also keep my project running.
There IS actually a workaround for that (most people dont know of this) but there is a guy that created a snippet to get around this.
```
// If this is a nested table, prevent the page from breaking
if ($this->_in_table > 1) {
Helpers::dompdf_debug("page-break", "table: nested table");
return false;
}
// Prevent page breaking on rowspan cells. If child frames count of this table row less then column count of table , than it is likely that row touched by previous rowspan, prevent page from breaking
if ($table && $table->get_cellmap() && $table->get_cellmap()->frame_exists_in_cellmap($frame) && $table->get_cellmap()->get_num_cols() > iterator_count($frame->get_children())) {
$cellmap = $table->get_cellmap();
$table_columns_count = $cellmap->get_num_cols();
$row_number = $cellmap->get_spanned_cells($frame)["rows"][0];
// Iterate through previous rows, to find and check spanned cell
$prev_row = $frame;
while ($prev_row && $table_columns_count > iterator_count($prev_row->get_children())) {
$prev_row = $prev_row->get_prev_sibling();
// Check that we don't rollback all the way up to first row
if ($prev_row) {
// Looking for spanned cell in row
foreach($prev_row->get_children() as $child) {
$frame_rows = $cellmap->get_spanned_cells($child)["rows"];
if($frame_rows && in_array($row_number, $frame_rows)) {
Helpers::dompdf_debug("page-break", "table-row: contains verified spanned cell");
return false;
}
}
}
}
Helpers::dompdf_debug("page-break", "table-row/row-groups: break allowed");
return true;
}
```
Hope that helps
Mit freundlichem GrußJens Horing___________________________Kontakt:Jens HoringJH Solution Consulting GmbHBüro Wiesbaden:Ahornstraße 265207 WiesbadenTel: 06122-705099Fax: 06122-705097Handy: 0177-7645431E-Mail: ***@***.***: www.horing.com
|
Looks like you're referring to #2090? While that does improve the rendering I don't know that it's a good enough solution to the problem. Though it has been a while since I've reviewed the issue so it's possible that might be a good basis for a solution. |
Sorry about the "soon", in my case it's the end of this month. Sorry for insisting with this, everything is perfect for our project with the library, except this bug. Sadly, there are tables generated that contain cells that span multiple rows (sometimes a cell could even go on 3 pages, starts on page 1, occupies page 2 fully and ends on page 3). So the solution to not allow page-break is not good for us. |
Hey Brian,thats why I posted this snipped. Sometimes its better not to start by 0JensVon meinem/meiner Galaxy gesendet
-------- Ursprüngliche Nachricht --------Von: Brian Sweeney ***@***.***> Datum: 09.02.23 00:12 (GMT+00:00) An: dompdf/dompdf ***@***.***> Cc: Jens Horing ***@***.***>, Comment ***@***.***> Betreff: Re: [dompdf/dompdf] Rowspanned TD element lost on page break (#1388)
Looks like you're referring to #2090? While that does improve the rendering I don't know that it's a good enough solution to the problem. Though it has been a while since I've reviewed the issue so it's possible that might be a good basis for a solution.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Would this cell have content as well? The case cited by the OP here is that a rowspanned cell that fully renders on the first page does not render at all on the next. In this scenario, the cell does not flow to the next page because it has been fully rendered. This issue is still challenging but the solution is more straightforward, and that's to ensure the cell flows alongside the rows it spans. If the rowspanned cell has content that has to span multiple pages, that's a bit of a different issue. That's a more fundamental problem with Dompdf because when an element has to be split for rendering to a new page Dompdf does not return to the previous page to pick up where it left off. Though I have been pondering this issue, it's a more challenging problem to solve. |
Yes, it has content, but most of the time it's not that much. But yes, there are cases where the content will have to be drawn on both pages, some of it on one page and the rest on the other. I would say that 95% of the situations there is little content, that can be drawn on either page. Another issue could be vertical centering in this case and i have no idea how it would work. |
has this problem been solved? i have the same problem |
建议直接使用lampnick/doctron(docker服务 页面转图片或者pdf)搭建服务,然后在服务端通过mvc渲染出一个pdf,通过docker服务来生成图片pdf完成度可以达到98%。不过具体看每个人的具体需求 |
what does this mean ? |
hub.docker.com Learn about the container lampnick/doctron |
I started looking at this issue though I don't have a timeline for resolution yet. |
This is a 5 year problem. Would be very nice if it works like it logically supposed to. I'm using it since 2018 and it's very annoying to explain to my clients that this is a dependency problem, cannot do anything without more "time/money" input. So, it is, what it is... We are open source and the licence don't have any guarantees. If nobody is wanting to solve the problem, not even the clients when I talk about "money/time" input, I can just think that this is good enough as it is... |
As I said I'm working on this issue now, so I wouldn't recommend anybody put any time into it just yet. I have a work-in-progress branch but right now it only addresses paging of tables and floats, not the rowspan issue. After reviewing current functionality I need to do a bit of refactoring. Once that's done I think I'll be able to address paging rowspans. At that point I'll open a PR and anyone who wants to help by testing the update and submitting feedback is more than welcome. |
I very much appreciate your work and I think other too. Thank you for your time spend in this project! |
Although this is not a good idea, I have found a relatively suitable method to generate pdf. 1. Use knplabs/knp-snap to generate pdf. 2. Use mikehaertl/php-pdftk to manage permissions on pdf. This will perfectly solve htmltopdf But here I also hope that TCpdf can do better. |
I have a temporary solution for this but I didn't use the row span instead I counted the row that my page will print here's my solution:
|
Hey, sorry to ask about this again, are there any updates on this issue? Any chances for this to be fixed in the next update? |
Not the next update but there is work-in-progress to address the issue in the paging-updates branch. |
Since it's still WIP, I will share how I achieve what I need. Not sure it will be helpful to other people but it's quite enough for me To achieve this, I need to remove all the rowspan in my So i defined a class
Then the table content will be something like this. Can just loop it 10 or 20 times and play around with it
|
if we are using a static table then we can add a class to that particular row where the table breaks and we can apply CSS like |
This issue is still present. 2.0.1 version. |
I have a table with merged cells in several rows, but when I use dompdf and performs a page break, the cells are not created correctly.
How can I correct it?
Thanks.
Table: https://jsfiddle.net/shinseiki86/24LL3fd5/
Result:
The text was updated successfully, but these errors were encountered: