PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Apr 21, 2021 10:35 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Feb 04, 2016 4:53 pm 

Joined: Thu Feb 04, 2016 4:35 pm
Posts: 2
For me the XGraphicsPath.Widen seems to be broken.

Given this original path:
pdfsharp_original.jpg [ 11.56 KiB | Viewed 3422 times ]

I tried with XGraphicsPath.Widen(...) on both, Pdfsharp 1.32.3057 as well as 1.50.4000-beta3b.
Used code can be found at the end of this post.

On Pdfsharp 1.32.3057 the result looks as follows:
pdfsharp_stable.jpg [ 33.99 KiB | Viewed 3422 times ]

On Pdfsharp 1.50.4000-beta3b the widen method seems to do nothing, the result looks as follows:

Here is the code I used:
        private XPoint cmPoint(double x, double y)
            return new XPoint(

        private XGraphicsPath getMyPath2()
            XGraphicsPath path = new XGraphicsPath();
            path.AddLine(cmPoint(0, 0), cmPoint(5, 2));
            path.AddLine(cmPoint(5, 2), cmPoint(10, 0));
            path.AddLine(cmPoint(10, 0), cmPoint(10, 10));
            path.AddLine(cmPoint(10, 10), cmPoint(0, 10));

            return path;

        private void button3_Click(object sender, RoutedEventArgs e)
            // Create a temporary file
            string filename = String.Format("{0}_tempfile.pdf", Guid.NewGuid().ToString("D").ToUpper());

            XPen penBlack = new XPen(XColors.Black, 1);
            XPen penRed = new XPen(XColors.Red, 1);

            PdfDocument pdfDocument = new PdfDocument();

            PdfPage page = pdfDocument.AddPage();
            page.Size = PdfSharp.PageSize.A1;

            XGraphics gfx = XGraphics.FromPdfPage(page);

            //give us some space to the left and top
            gfx.TranslateTransform(XUnit.FromCentimeter(3), XUnit.FromCentimeter(3));

            XGraphicsPath path = getMyPath2();
            gfx.DrawPath(penBlack, path);

            path.Widen(new XPen(XColors.Red, XUnit.FromCentimeter(1)));
            gfx.DrawPath(penRed, path);

            // Save the pdfDocument...
            // ...and start a viewer

Expected result:
The result of Pdfsharp 1.32.3057, but without these weird triangles.

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group