-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
wxPDF_BORDER_RIGHT doesn't work as expected. #81
Comments
In principle, it does work. However, under certain circumstances one gets unexpected/unwanted results.
Admittedly, that is a known deficiency. It has to do with the order in which drawing and filling operations are applied. Currently, each table cell is drawn on its own, without taking into account surrounding cells. Let cell A and B be adjacent cells, A on the left, B on the right. First, the right border of A will be drawn, but then thereafter the filling of B will - at least partially - overdraw the right border of A. Actually, it would be necessary to separate filling and drawing of table cells into 2 steps: first filling all cells, then drawing all borders.
Only the cells in every other row are drawn with a fill color. For the unfilled cells the right border is completely visible, for the filled cells the border is partially overdrawn with the fill color. It will be difficult, if not impossible, to adjust the current table drawing code in such a way that borders and fill colors are always applied correctly.
That is to be expected, because the cell left of the current cell will be drawn first, and then the left border of the current cell. That is, the left border is always on top.
Yes, that is correct. BTW, bottom and top borders will be affected in a similar way. Due to the Christmas holidays, I will only look into the issue in January. However, I really don't know whether this issue can be fixed without major efforts. |
All right, back from my christmas vaccation, I'd the possibility to rethink the issue. Probably I was wrong with identifying Reviewing my origin problem I encountered that I was confused that right borders doesn't appear when using the I would assume, that borders of table cells doesn't overlap. So, I had a look into wxPdfTable and how the borders are drawn there: A possible fix would be to include the borders into the cell they belongs to. Therefore we can calculate an offset. Here, how I adjusted wxPdfTable::WriteRow in pdfxml.cpp after line 605
My first tests with that are looking good. In case this is a solution for you, I attached a path file with my adjustments. Edit: The solution is not complete. The border could be over text, for example right border over right aligned text. I'll look in the alignment part too. |
I haven't looked into the issue in detail yet for the very same reason.
Yes, indeed. There is not much that can be done about the
Exactly.
Yes, the table drawing via markup should be adjusted to match expectations. However, this may not be possible to accomplish easily.
IMHO this assumption doesn't hold true, unfortunately - at least not under all circumstances. If we have 2 adjacent cells and we apply a right border to the left cell and a left border to the right cell, the typical user expectation is that the borders are collapsed into a single border, and not to have an actual border between the cells twice as wide as a single cell border.
A simpler and cleaner approach meeting user expectations would probably be to draw a table not in one pass (as is done now), but in 2 or 3 passes:
Matters are complicated by the fact that a table can span more than one page. That is, method |
My first patch file had the wrong default line offset. Using the last line width would do the trick
instead of
In fact, I wouldn't expect that the borders are collapsed. At least HTML doesn't collapse borders automatically. See for example:
For borders at table level, HTML has a special "collapse" style. I think, most people would expect a similar behavior than in HTML. But, of course, changing the behavior of the mark up can break code of people using it, since currently the cells are sharing their border. I added an adjusted patch file, using the correct offset for an HMTL like result: pdfxml.patch But, in case you want to have collapsing borders as default, the functions need a redesign. But I won't come with an proposal for such a solution today. |
Well, expectations may vary, I agree. However, the current behaviour in wxPdfDocument is that cell borders of a table are collapsed. Yes, borders are drawn for each cell separately, but they are drawn on top of each other, resulting in collapsed borders.
You are right. However, the markup dialect currently supported by wxPdfDocument doesn't support neither style attributes nor CSS. And at the moment there are no plans to extend the markup dialect.
Currently, the table implementation in the wxPdfDocument markup dialect uses implicitly
Maybe. However, that the default value of the HTML attribute
That's the most important point. Changing the behaviour as you did in your patch proposal will break existing code. I'm not against adding additional features like separate cell borders, but it is also necessary to support collapsed cell borders as that was the default behaviour up to now.
Implementing properly drawn collapsing borders will require some method redesign, but I fear that additionally supporting separate borders and combinations of separate and collapsed borders will cause a major effort. |
I just implemented a version which follows your suggestion, to draw first the backgrounds, then the cell borders and at last the content. For printing tables over more than one page, it was necessary to precalculate the page header, so that the number of pages can be determined before the writing of the the table starts. Please feel free to accept/decline/modify pull request #82 which contains my proposal for the discussed changes. |
Great.
Agreed. Up to now that was not necessary, because the y position was implicitly set correctly after each page break.
I will review the PR. |
I think wxPDF_BORDER_RIGHT doesn't work as expected:
Initially, I encountered that I don't get a right border around table cells when using the mark up language with colored rows.
So I played a bit around with the samples and were able to reproduce the issue with sample 5:
Considering in sample5.cpp the funcion FancyTable(), I adjusted it in a way that just the first column should have a right border:
the result is:

which looks wrong.
creates a correct table with a left border from the left column. Even a left border from the second column creates a correct border.
The same tests with the function ImprovedTable() produce the correct output. So it seems to be a problem with the combination of filling and right border.
(Tested with wxPDFDoc v1.0.2 and wxWidgets 3.2.1)
The text was updated successfully, but these errors were encountered: