PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat May 26, 2018 5:41 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Mar 11, 2013 7:59 pm 
Offline

Joined: Mon Mar 11, 2013 7:30 pm
Posts: 1
A path containing several open figures with a closed figure in the middle will not close correctly. It will treat the entire path as a single closed figure. Issue was fixed by updating get accessor in the XGraphicsPath.CurrentPathFigure property.

The code originally read:

Code:
        /// <summary>
        /// Gets the current path figure.
        /// </summary>
        private PathFigure CurrentPathFigure
        {
            get
            {
                int count = this.pathGeometry.Figures.Count;
                if (count == 0)
                {
                    this.pathGeometry.Figures.Add(new PathFigure());
                    count++;
                }
                else if (this.startNewFigure && this.pathGeometry.Figures[count - 1].Segments.Count == 0)
                {
                    this.pathGeometry.Figures.Add(new PathFigure());
                    count++;
                }
                return this.pathGeometry.Figures[count - 1];
            }
        }

The apparent logic error is the '==' conditional in the else if statement. With fix, the code reads:

Code:
        /// <summary>
        /// Gets the current path figure.
        /// </summary>
        private PathFigure CurrentPathFigure
        {
            get
            {
                int count = this.pathGeometry.Figures.Count;
                if (count == 0)
                {
                    this.pathGeometry.Figures.Add(new PathFigure());
                    count++;
                }
                else if (this.startNewFigure && this.pathGeometry.Figures[count - 1].Segments.Count > 0)
                {
                    this.pathGeometry.Figures.Add(new PathFigure());
                    count++;
                }
                return this.pathGeometry.Figures[count - 1];
            }
        }


With fix, only the closed figure is closed and other figures remain open.


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 12, 2013 9:13 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2815
Location: Cologne, Germany
Thank you very much for the feedback.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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