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

Zero width or height clipping rectangles don't work
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3209
Page 1 of 1

Author:  zanadar [ Wed Oct 07, 2015 12:14 am ]
Post subject:  Zero width or height clipping rectangles don't work

Hi,

I have a scenario where I am converting an EMF to PDF using PDFSharp and a clipping rectangle with zero with and height is not working.
A zero with or height clipping rectangle is used to hide the output from drawing commands.

The code at fault is the use of System.Drawing2D.GraphicsPath.AddRectangle at XGraphicsPath.AddRectangle(XRect).

replace the contents of this function with

this.gdipPath.StartFigure();
this.gdipPath.AddLines( new PointF[] { rect.TopLeft.ToPointF(), rect.TopRight.ToPointF(), rect.BottomRight.ToPointF(), rect.BottomLeft.ToPointF() } );
this.gdipPath.CloseFigure();

Which successfully initialises the GraphicsPath with the zero with or height rectangle and allows clipping to be performed on this path.

Cheers
Ryan

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