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

Border in PDF has line even if the thickness is 0
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3497
Page 1 of 1

Author:  shenglanl [ Wed Nov 16, 2016 10:58 pm ]
Post subject:  Border in PDF has line even if the thickness is 0

I have a foot border defined with its Thickness as (1,0,1,1) and CornerRadius as (0,0,4,4). The border on PDF always shows the top with very thin line until I set the CornerRadius as (0,0,0,0) or zoom in the PDF file into 800%. Following are the code
Code:
Border footBorder = new Border() {
                BorderBrush = Brushes.Green,
                BorderThickness = new Thickness(1, 0, 1, 1),// not border on the top
                Margin = new Thickness(2,0,2,0),
                //SnapsToDevicePixels = true,
                UseLayoutRounding = true,
                Height = 4,
                CornerRadius = new CornerRadius(0, 0, 4, 4)// corner radius only applied to leftbottom and rightbottom
            };
            if (!string.IsNullOrWhiteSpace(footerNote))
            {
               
                TextBlock tbFooter = new TextBlock() {
                    Text = footerNote,
                    FontSize = 12,
                    //Margin = new Thickness(5)
                };
                footBorder.Child = tbFooter;
                footBorder.BorderThickness = new Thickness(1, 1, 1, 1); // border on the top
            }
            else
            {
                footBorder.Child = new TextBlock() {
                    Text = "   ",
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Margin = new Thickness(0), /*Padding = new Thickness(0), Background = Brushes.Gray,*/ //SnapsToDevicePixels = true,
                    UseLayoutRounding = true,
                    Height = 4
                };
                //footBorder.BorderThickness = new Thickness(1, 0, 1, 1); // not border on the top
            }
            BlockUIContainer footContainer = new BlockUIContainer(footBorder);
            section.Blocks.Add(footContainer);


Here is what the foot border looks like in the saved PDF file:
Attachment:
File comment: The foot border in PDF file now
FootBorder.jpg
FootBorder.jpg [ 8.04 KiB | Viewed 4524 times ]
. There should not have the light green top line.

Is there any bug in PDFSharp to render the border with CornerRadius set to non-zero?


Thanks!

Author:  Thomas Hoevel [ Thu Nov 17, 2016 9:11 am ]
Post subject:  Re: Border in PDF has line even if the thickness is 0

Hi!
shenglanl wrote:
Is there any bug in PDFSharp to render the border with CornerRadius set to non-zero?
I don't know.
We will investigate this issue if we get a VS solution or an MDDDL file that allows us to replicate the issue.
See also:
viewtopic.php?f=2&t=832

Nothing in your code snippet looks like PDFsharp code.

Author:  shenglanl [ Thu Nov 17, 2016 6:02 pm ]
Post subject:  Re: Border in PDF has line even if the thickness is 0

Thank you, Thomas, for your quick response.

Yes, the code snippet I posted above is C# code to generate a FixDocument which XpsDocumentWriter can use to write a xps file. We use PDFSharp to convert the saved xps file into a pdf file.
Code:
PdfSharp.Xps.XpsConverter.Convert(xpsFileName, pdfFileName, 0);


I saved the temporary xps file and the pdf file and attatched their zip file below. It looks the xps file doesn't have the issues as I pointed in the pdf file.

If you still need an example VS solution for debugging, I have to create a simple one. This VS example solution is too big and with the production code behind.

Attachments:
File comment: Both XPS file and PDF file
BorderIssues.zip [142.26 KiB]
Downloaded 333 times

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