PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu May 25, 2017 2:32 pm

All times are UTC




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

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

Given this original path:
Attachment:
pdfsharp_original.jpg
pdfsharp_original.jpg [ 11.56 KiB | Viewed 1009 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:
Attachment:
pdfsharp_stable.jpg
pdfsharp_stable.jpg [ 33.99 KiB | Viewed 1009 times ]


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

Here is the code I used:
Code:
        private XPoint cmPoint(double x, double y)
        {
            return new XPoint(
                XUnit.FromCentimeter(x),
                XUnit.FromCentimeter(y)
                );
        }


        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));
            path.CloseFigure();

            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...
            pdfDocument.Save(filename);
            // ...and start a viewer
            Process.Start(filename);
        }


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


Top
 Profile  
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 4 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:  
Powered by phpBB® Forum Software © phpBB Group