PdfGraphics.IntersectClip(RectangleF) Method
Assigns the clip region of the PdfGraphics object to the intersection of the current clip region and the specified page region.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.1.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
Declaration
Parameters
Name | Type | Description |
---|---|---|
rect | RectangleF | A RectangleF structure that intersects the current clip region of the PdfGraphics object (defined in world coordinate system). |
Remarks
This method allows you to crop the clip region of the PdfGraphics object. Use the PdfGraphics methods (like GDI+) to draw the updated clip region. Refer to the following article for a list of supported drawing method: PDF Graphics API. Then, call the PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackground, or PdfDocumentProcessor.RenderNewPage method to add the resulting graphics to a document page.
The code sample below sets the clip region of the PdfGraphics object to the intersection of the current clip region and the specified page region.
using DevExpress.Pdf;
using System.Drawing;
//...
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
processor.CreateEmptyDocument();
PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
using (PdfGraphics graphics = processor.CreateGraphics())
{
graphics.SaveGraphicsState();
// Specify the page region that intersects the clip region.
Rectangle clipRect = new Rectangle(100, 100, 200, 200);
// Set the clip region to the intersection of
// the current clip region with the specified rectangle.
graphics.IntersectClip(clipRect);
// Draw the updated clip region.
using (var brush = new SolidBrush(Color.Blue))
graphics.FillRectangle(brush, new RectangleF(0, 0, 500, 500));
graphics.RestoreGraphicsState();
// Add graphics content to the target page.
graphics.AddToPageForeground(page, 72, 72);
}
processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");