PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

MigraDoc border when background is transparent
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3680
Page 1 of 1

Author:  bhobinca [ Mon Oct 30, 2017 6:55 am ]
Post subject:  MigraDoc border when background is transparent

Hello,
I'm not sure whether this is a bug or I'm messing something up when using MigraDoc. I would really appreciate a bit of help here.

What I am trying to do is have a table with no borders, on a pdf that has a background image. The background image should be seen through the table. All works well if I don't assign any color to the background of the table.
However, if I want the table rows to have alternative colors (lets say transparent white and a transparent light shade of gray) the borders of the table start becoming visible.
This only happens when the background color I assign to rows is darker and transparent. I also tried to set the borders to be of the color I set on the background, but that had no effect. Oh, and also set the Visible property to false, but again, no change.
Am I doing something wrong? Maybe setting the wrong property?

CODE:
Code:
            var row = table.AddRow();
            row.Cells[0].AddParagraph("A");
            row.Shading.Color = new Color(50, 50, 50, 50);
            row = table.AddRow();
            row.Cells[0].AddParagraph("B");
            row.Shading.Color = new Color(50, 50, 50);
            row = table.AddRow();
            row.Cells[0].AddParagraph("C");
            row.Shading.Color = new Color(200, 200, 200);
            row = table.AddRow();
            row.Cells[0].AddParagraph("D");
            row.Shading.Color = new Color(50, 255, 255, 255);


Row A is the one with the issue. The rest are to show that other combinations work well.
MDDDL
Code:
\table
    [
      Borders
      {
        Width = 0
      }
    ]
    {
      \columns
      {
        \column
        \column
      }
      \rows
      {
        \row
        [
          Shading
          {
            Color = 0x32323232
          }
        ]
        {
          \cell
          {
            A
          }
        }
        \row
        [
          Shading
          {
            Color = RGB(50,50,50)
          }
        ]
        {
          \cell
          {
            B
          }
        }
        \row
        [
          Shading
          {
            Color = RGB(200,200,200)
          }
        ]
        {
          \cell
          {
            C
          }
        }
        \row
        [
          Shading
          {
            Color = 0x32FFFFFF
          }
        ]
        {
          \cell
          {
            D
          }
        }
      }
    }


The version I first noticed this on was MigraDoc WPF 1.32.2608 (from nuget), but I also downloaded the issue submission project and it happened there too, and that was version 1.50.4000-beta3b.
I have the issue submission project ready to upload if needed. I haven't uploaded it yet because I still think maybe I'm doing something wrong.

You can see the issue in the following image, on row A. In the middle of it there's a visible border between the cells.

Thank you for your time and for an amazing library!

Attachments:
TransparentBorderIssue.PNG
TransparentBorderIssue.PNG [ 8.65 KiB | Viewed 5764 times ]

Author:  TH-Soft [ Mon Oct 30, 2017 8:50 am ]
Post subject:  Re: MigraDoc border when background is transparent

Hi!

Using Adobe Reader? It sometimes has display errors 1 pixel wide. If you zoom in, the error still is one pixel wide or goes away.

That's what I guess the problem is (can't check this with a PNG, could check this with a PDF).

What you see is probably not the border, but an overlap between two cells that only overlap due to a rounding error.

Author:  bhobinca [ Mon Oct 30, 2017 9:08 am ]
Post subject:  Re: MigraDoc border when background is transparent

Yes, I was opening it using Adobe Reader. I see now that different viewers make it look different. However, in 3/4 that line appeared there. The only that didn't was whatever google drive uses to open pdfs.
Zooming in still shows the problem.

I should maybe try to print it and see if that shows on the printed page. However, even if it only gets displayed on adobe reader, it still might be too much of an issue. Any idea what I could do to fix/hide it?

I also attached the pdf so anyone can check it out. (Had to zip it because for some reason trying to upload it as a PDF I got error "Invalid image" on the forum)

Thanks again for the help!

Attachments:
HelloWorld.zip [9.14 KiB]
Downloaded 323 times

Author:  TH-Soft [ Mon Oct 30, 2017 9:13 am ]
Post subject:  Re: MigraDoc border when background is transparent

bhobinca wrote:
Zooming in still shows the problem.
Yes. As I expected: you see a thin line at any zoom level (100% or 6400%).
The error will be one pixel when printing - and should hardly be visible if visible at all.

Would a gap be better? Having transparent borders or padding could lead to gaps between the cell backgrounds.

Author:  bhobinca [ Mon Oct 30, 2017 9:31 am ]
Post subject:  Re: MigraDoc border when background is transparent

A gap would be ok only if I can properly mask it to seem like it's not there. Which it seems I cannot. I tried now to make borders transparent or the color I want in the background of the row, but it is still very obvious the border is there.

I'm going to try some more, but I don't really know how best to approach it now.

But thanks for helping me understand the issue.
If you happen to stumble upon anything that might help me, any suggestion/idea is appreciated.

Short version of what I'm trying to accomplish:
borderless table, with alternative row backgrounds which need to be semi-transparent to be able to see the logo that will be on the background of the page.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/