PdfGraphics.DrawBezier(Pen, PointF, PointF, PointF, PointF) Method
Draws a Bezier curve specified by four points (in the world coordinate system).
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Drawing.dll
NuGet Package: DevExpress.Pdf.Drawing
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
pen | Pen | A Pen object that specifies the color, width, and style of the curve. |
pt1 | Point |
A Point structure that specifies the start point of the curve. |
pt2 | Point |
A Point structure that specifies the first control point of the curve. |
pt3 | Point |
A Point structure that specifies the second control point of the curve. |
pt4 | Point |
A Point structure that specifies the end point of the curve. |
#Remarks
The Bezier curve starts from the first point and ends at the fourth point. The second and third points are control points that specify the shape of the curve. To draw a Bezier curve, pass the pen parameter and point parameters (pt1, pt2, pt3, pt4) to the DrawBezier method.
To draw a shape on the PDF page, use one of the following methods:
- PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackground
- These methods allow you to draw content on an existing page.
- PdfDocumentProcessor.RenderNewPage
- Draws content on a new page.
The code sample below draws a Bezier curve using the four specified points.
using DevExpress.Pdf;
using System.Drawing;
//...
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
processor.CreateEmptyDocument();
PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
using (PdfGraphics graphics = processor.CreateGraphics())
{
// Draw a Bezier curve.
using (var pen = new Pen(Color.Red, 5))
graphics.DrawBezier(pen, new PointF(100, 750),
new PointF(170, 100), new PointF(300, 500),
new PointF(400, 100));
// Add graphics content to the document page.
graphics.AddToPageForeground(page, 72, 72);
}
processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");