Skip to main content
All docs
V25.1
  • PdfGraphics.DrawLines(DXPen, PointF[]) Method

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

    Namespace: DevExpress.Pdf

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

    NuGet Package: DevExpress.Pdf.Drawing

    Declaration

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

    Parameters

    Name Type Description
    pen DXPen

    A DXPen 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 DevExpress.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 DXPen(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