Skip to main content
.NET Framework 4.5.2+

PdfGraphics.DrawLines(Pen, PointF[]) Method

Draws a series of lines that connect points from the specified array.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void DrawLines(
    Pen pen,
    PointF[] points
)

Parameters

Name Type Description
pen Pen

A Pen object that specifies the color, width, and style of the lines.

points PointF[]

An array of PointF structures that specifies points to connect (in world coordinate system).

Remarks

The first two points of the points array specify the first line. Each next line connects the previous line’s end point and the next array point. Pass the points and pen parameters to the DrawLines method to draw a series of lines.

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 series of lines by seven points.

Draw a Series of Lines

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

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    processor.CreateEmptyDocument();
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        using (PdfGraphics graphics = processor.CreateGraphics())
        {
            // Create a point array.
            PointF[] points = new PointF[] 
            { 
                new PointF(100, 100), 
                new PointF(200, 10), 
                new PointF(450, 150), 
                new PointF(500, 400), 
                new PointF(400, 550), 
                new PointF(550, 650), 
                new PointF(500, 700) 
            };

            // Draw a series of lines.
            using (var pen = new Pen(Color.Red, 5))
                graphics.DrawLines(pen, points);

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
See Also