wxPdfDocument Cell Border Thickness Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

wxPdfDocument Cell Border Thickness

Post by iwbnwif »

Environment: wxWidgets 2.9.5, MSW 8, mingw 4.7.1, wxPdfDoc 0.9.4

I have been trying to find a way to change the thickness of the border line drawn around a 'cell' in wxPdfDoc, however despite looking at the source code and examples I can't find a way (with the exception of rendering the appropriate parts of the document using xml).

Has anyone else come across / solved this problem.

The main reason is that if I combine wxPDF_BORDER_FRAME and filling the cell with a background color the border line becomes very thin or disappears. This is apparent in both Foxit and Adobe readers

TIA
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument Cell Border Thickness

Post by utelle »

iwbnwif wrote:I have been trying to find a way to change the thickness of the border line drawn around a 'cell' in wxPdfDoc, however despite looking at the source code and examples I can't find a way (with the exception of rendering the appropriate parts of the document using xml).

Has anyone else come across / solved this problem.
Well, I'd recommend you take a second look at sample "tutorial3" and read the comments within the source file "tutorial3.cpp". It demonstrates exactly how to accomplish a framed cell with a background color. It is required to set the colors you want for the background, the frame and the text, and you have to set the line width (method SetLineWidth) before doing a call to method Cell.
iwbnwif wrote:The main reason is that if I combine wxPDF_BORDER_FRAME and filling the cell with a background color the border line becomes very thin or disappears. This is apparent in both Foxit and Adobe readers
It's a known problem that thin lines are sometimes not correctly displayed on screen due to low resolution (compared to printer output). On paper usually all looks as expected.

Regards,

Ulrich
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxPdfDocument Cell Border Thickness

Post by iwbnwif »

Ulrich,

Many thanks for such a fast and helpful response. You are right, I missed the SetLineWidth call :oops: (it is very obvious now, but I was looking for something to do with "border").

I have noticed the thin line problem with PDF on other software too especially LibreOffice, but it seems to me that when filling the fill overwrites the border line. Is there any way for the fill to be painted first and then the border drawn on afterwards?
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument Cell Border Thickness

Post by utelle »

iwbnwif wrote:I have noticed the thin line problem with PDF on other software too especially LibreOffice, but it seems to me that when filling the fill overwrites the border line. Is there any way for the fill to be painted first and then the border drawn on afterwards?
It depends on how the software handles filling and framing a cell. wxPdfDocument uses in its method Cell internal PDF commands for creating a filled and framed rectangle. If not all 4 borders are required, lines for the requested borders are drawn after filling the cell. So this should work as expected.

Nevertheless, when using XML tables wxPdfDocument could certainly be improved: if a table cell is filled with a background color, but without a border, the background color may partially cover the border lines of adjacent cells - as can be seen in the XML sample coming with wxPdfDocument. This is due to the fact that table cells including fill and border are created one by one. However, to overcome the problem it would be necessary to first create the fills for all cells before creating the borders for all cells.

Regards,

Ulrich
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxPdfDocument Cell Border Thickness

Post by iwbnwif »

Thank you again for your response. I think this explains the problem I am seeing.

I am creating small grid / table and apart from the top row and left column I am only asking for the bottom and right borders. I think what is happening is that when filling the next adjacent cell it is partially covering the border already painted for the preceding cell.

Unfortunately I want to change the fill color based on the contents of the cell so I can't fill the whole table first.

I can see that its a difficult problem to solve in wxPdfDocument because each cell knows nothing about the other cells so cannot adjust its fill size. The only thing I can think of is to use z-ordering with fills placed on a lower level than borders, but I don't know if such a thing exists in PDF.

I think I can get around the problem to some extent by working the grid top left and drawing left / top borders until the rightmost column and bottom row.

Thanks again for your help and for wxPdfDocument :)
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument Cell Border Thickness

Post by utelle »

iwbnwif wrote:I am creating small grid / table and apart from the top row and left column I am only asking for the bottom and right borders. I think what is happening is that when filling the next adjacent cell it is partially covering the border already painted for the preceding cell.
That's exactly the problem.

In some situations there are work-arounds like adding a row or column of very low height or width, if setting background colors is required, but only borders for whole rows or whole columns are necessary.
iwbnwif wrote:Unfortunately I want to change the fill color based on the contents of the cell so I can't fill the whole table first.
It's a common request to be able to set the background color of individual cells and adding borders. And of course I agree that wxPdfDocument should provide a solution for this. However, at the moment it's not supported unfortunately.
iwbnwif wrote:I can see that its a difficult problem to solve in wxPdfDocument because each cell knows nothing about the other cells so cannot adjust its fill size. The only thing I can think of is to use z-ordering with fills placed on a lower level than borders, but I don't know if such a thing exists in PDF.
AFAIK the PDF standard does not define z-odering. However, it can be mimiced. In the long run I plan to change the wxPdfDocument implementation to correctly draw tables with cell backgrounds and cell borders. However, I can't tell you when this will be available as it will definitely be a major change.

Regards,

Ulrich
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxPdfDocument Cell Border Thickness

Post by iwbnwif »

For now, starting in the top left and using wxPDF_BORDER_TOP | wxPDF_BORDER_LEFT until the last column and ultimately last row works well enough for me at this time. :)
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Post Reply