Back to Devexpress

PdfGraphics.DrawBeziers(DXPen, PointF[]) Method

officefileapi-devexpress-dot-pdf-dot-pdfgraphics-dot-drawbeziers-x28-devexpress-dot-drawing-dot-dxpen-system-dot-drawing-dot-pointf-x29.md

latest5.0 KB
Original Source

PdfGraphics.DrawBeziers(DXPen, PointF[]) Method

Draws a series of Bezier curves specified by four points (in the world coordinate system).

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Drawing.dll

NuGet Package : DevExpress.Pdf.Drawing

Declaration

csharp
public void DrawBeziers(
    DXPen pen,
    PointF[] points
)
vb
Public Sub DrawBeziers(
    pen As DXPen,
    points As PointF()
)

Parameters

NameTypeDescription
penDXPen

A DXPen object that specifies the color, width, and style of the curve.

| | points | PointF[] |

An array of PointF structures that specifies points (in world coordinate system) by which you can draw a series of Bezier curves.

|

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 DrawBeziers method.

To draw a series of Bezier curves, generate an array of points. The point item number is a multiple of 3 plus 1, such as 4, 7, or 10. Assign the array to the points parameter. Pass the points and pen parameters to the DrawBeziers method

To draw a shape on the PDF page, use one of the following methods:

PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackgroundThese methods allow you to draw content on an existing page.PdfDocumentProcessor.RenderNewPageDraws content on a new page.

The following code snippet draws a Bezier curve using seven points.

csharp
using DevExpress.Pdf;
using System.Drawing;
using DevExpress.Drawing;
//...

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    processor.CreateEmptyDocument();
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        using (PdfGraphics graphics = processor.CreateGraphicsWorldSystem())
        {
            // Create a point array.
            PointF[] points = new PointF[]
            {
              new PointF(100, 100),
              new PointF(200, 10),
              new PointF(350, 50),
              new PointF(500, 100),
              new PointF(600, 150),
              new PointF(550, 250),
              new PointF(500, 300)
            };
            // Draw a Bezier curve.
            using (var pen = new DXPen(Color.Red, 5))
            graphics.DrawBeziers(pen, points);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
vb
Imports DevExpress.Pdf
Imports System.Drawing
Imports DevExpress.Drawing
'...

Using processor As New PdfDocumentProcessor()
    processor.CreateEmptyDocument()
    Dim page As PdfPage = processor.AddNewPage(PdfPaperSize.A4)
        Using graphics As PdfGraphics = processor.CreateGraphicsWorldSystem()

        ' Create a point array.
            Dim points() As PointF = {
                New PointF(100, 100),
                New PointF(200, 10),
                New PointF(350, 50),
                New PointF(500, 100),
                New PointF(600, 150),
                New PointF(550, 250),
                New PointF(500, 300)
            }

            ' Draw a Bezier curve.
            Using pen As New DXPen(Color.Red, 5)
            graphics.DrawBezier(pen, points)
            End Using

            ' Add graphics content to the document page.
            graphics.AddToPageForeground(page)
        End Using
    processor.SaveDocument("out2.pdf")
End Using
Process.Start("out.pdf")

See Also

PdfGraphics Class

PdfGraphics Members

DevExpress.Pdf Namespace