Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / DrawLine Method
The horizontal (X) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Example





In This Topic
    DrawLine Method (GdPicturePDF)
    In This Topic
    Draws a line on the currently selected page of the loaded PDF document according to what you have specified. All coordinates of the starting and ending points of the line need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page. The line is clearly defined by the its starting and ending points. The other line parameters, which you might prefer, for example, the line color or the line width, you are allowed to set by using the SetLineColor(Byte,Byte,Byte) method and the SetLineWidth method.

    You can simply use the GetMeasurementUnit method to determine the currently defined units and you can easily use the SetMeasurementUnit method to reset the units according to your preference.

    Syntax
    'Declaration
     
    
    Public Function DrawLine( _
       ByVal StartX As Single, _
       ByVal StartY As Single, _
       ByVal DstX As Single, _
       ByVal DstY As Single _
    ) As GdPictureStatus
    public GdPictureStatus DrawLine( 
       float StartX,
       float StartY,
       float DstX,
       float DstY
    )
    public function DrawLine( 
        StartX: Single;
        StartY: Single;
        DstX: Single;
        DstY: Single
    ): GdPictureStatus; 
    public function DrawLine( 
       StartX : float,
       StartY : float,
       DstX : float,
       DstY : float
    ) : GdPictureStatus;
    public: GdPictureStatus DrawLine( 
       float StartX,
       float StartY,
       float DstX,
       float DstY
    ) 
    public:
    GdPictureStatus DrawLine( 
       float StartX,
       float StartY,
       float DstX,
       float DstY
    ) 

    Parameters

    StartX
    The horizontal (X) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
    StartY
    The vertical (Y) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
    DstX
    The horizontal (X) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
    DstY
    The vertical (Y) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.

    Return Value

    A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

    We strongly recommend always checking this status first.

    Remarks
    Please note that this method is only allowed for use with non-encrypted documents.

    Be aware that the required line is drawn using the currently defined line attributes. For further assistance, please see the Graphics State section of the GdPicturePDF class in the Reference Guide.

    Example
    How to draw lines with different attributes.
    Dim caption As String = "Example: DrawLine"
    Dim oGdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = oGdPicturePDF.NewPDF()
    If status = GdPictureStatus.OK Then
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
        If (oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'The color used to draw the line.
           (oGdPicturePDF.SetLineWidth(0.5F) = GdPictureStatus.OK) AndAlso 'the line width
           (oGdPicturePDF.DrawLine(2, 2, 18, 2) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineWidth(0.3F) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.DrawLine(2, 4, 18, 4) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineColor(210, 105, 30) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineDash(2, 1) = GdPictureStatus.OK) AndAlso 'drawing a dash line
           (oGdPicturePDF.DrawLine(2, 6, 18, 6) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.DrawLine(2, 10, 18, 10) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.DrawLine(18, 6, 18, 10) = GdPictureStatus.OK) AndAlso
           (oGdPicturePDF.DrawLine(2, 6, 2, 10) = GdPictureStatus.OK) Then
            status = oGdPicturePDF.SaveToFile("test_DrawLine.pdf")
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
            Else
                MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
            End If
        Else
            MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + oGdPicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
    End If
    oGdPicturePDF.Dispose()
    string caption = "Example: DrawLine";
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    GdPictureStatus status = oGdPicturePDF.NewPDF();
    if (status == GdPictureStatus.OK)
    {
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
        if ((oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //The color used to draw the line.
            (oGdPicturePDF.SetLineWidth(0.5f) == GdPictureStatus.OK) && //the line width
            (oGdPicturePDF.DrawLine(2, 2, 18, 2) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineWidth(0.3f) == GdPictureStatus.OK) &&
            (oGdPicturePDF.DrawLine(2, 4, 18, 4) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineColor(210, 105, 30) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineDash(2, 1) == GdPictureStatus.OK) && //drawing a dash line
            (oGdPicturePDF.DrawLine(2, 6, 18, 6) == GdPictureStatus.OK) &&
            (oGdPicturePDF.DrawLine(2, 10, 18, 10) == GdPictureStatus.OK) &&
            (oGdPicturePDF.SetLineNoDash() == GdPictureStatus.OK) &&
            (oGdPicturePDF.DrawLine(18, 6, 18, 10) == GdPictureStatus.OK) &&
            (oGdPicturePDF.DrawLine(2, 6, 2, 10) == GdPictureStatus.OK))
        {
            status = oGdPicturePDF.SaveToFile("test_DrawLine.pdf");
            if (status == GdPictureStatus.OK)
                MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
            else
                MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
        }
        else
            MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + oGdPicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
    oGdPicturePDF.Dispose();
    See Also