The horizontal (X) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (Y) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (X) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (Y) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the starting point when drawing a line.
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the ending point when drawing a line.
Set this parameter to true, if you want to display the text specified by the Contents parameter as a caption in the appearance of the line, otherwise set it to false. The text should be rendered in a manner appropriate to the content, taking into account factors such as writing direction. The initial value is false.
The width of the line used to draw the line annotation, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the line annotation.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw the line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw the line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
The amount of red color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
The amount of green color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / AddLineAnnotation Method

AddLineAnnotation Method (GdPicturePDF)

In This Topic
Adds a line annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Line". This annotation displays a single straight line according to the defined parameters. When it is opened, it displays a pop-up window with the content according to what you have specified.

This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the line.

Syntax
'Declaration
 
Public Function AddLineAnnotation( _
   ByVal StartX As Single, _
   ByVal StartY As Single, _
   ByVal DstX As Single, _
   ByVal DstY As Single, _
   ByVal Title As String, _
   ByVal Contents As String, _
   ByVal StartCap As PdfAnnotationLineEndingStyle, _
   ByVal EndCap As PdfAnnotationLineEndingStyle, _
   ByVal ShowContent As Boolean, _
   ByVal LineWidth As Single, _
   ByVal LineStyle As PdfAnnotationBorderStyle, _
   ByVal LineDashOn As Single, _
   ByVal LineDashOff As Single, _
   ByVal Opacity As Single, _
   ByVal Red As Byte, _
   ByVal Green As Byte, _
   ByVal Blue As Byte _
) As Integer
public int AddLineAnnotation( 
   float StartX,
   float StartY,
   float DstX,
   float DstY,
   string Title,
   string Contents,
   PdfAnnotationLineEndingStyle StartCap,
   PdfAnnotationLineEndingStyle EndCap,
   bool ShowContent,
   float LineWidth,
   PdfAnnotationBorderStyle LineStyle,
   float LineDashOn,
   float LineDashOff,
   float Opacity,
   byte Red,
   byte Green,
   byte Blue
)
public function AddLineAnnotation( 
    StartX: Single;
    StartY: Single;
    DstX: Single;
    DstY: Single;
    Title: String;
    Contents: String;
    StartCap: PdfAnnotationLineEndingStyle;
    EndCap: PdfAnnotationLineEndingStyle;
    ShowContent: Boolean;
    LineWidth: Single;
    LineStyle: PdfAnnotationBorderStyle;
    LineDashOn: Single;
    LineDashOff: Single;
    Opacity: Single;
    Red: Byte;
    Green: Byte;
    Blue: Byte
): Integer; 
public function AddLineAnnotation( 
   StartX : float,
   StartY : float,
   DstX : float,
   DstY : float,
   Title : String,
   Contents : String,
   StartCap : PdfAnnotationLineEndingStyle,
   EndCap : PdfAnnotationLineEndingStyle,
   ShowContent : boolean,
   LineWidth : float,
   LineStyle : PdfAnnotationBorderStyle,
   LineDashOn : float,
   LineDashOff : float,
   Opacity : float,
   Red : byte,
   Green : byte,
   Blue : byte
) : int;
public: int AddLineAnnotation( 
   float StartX,
   float StartY,
   float DstX,
   float DstY,
   string* Title,
   string* Contents,
   PdfAnnotationLineEndingStyle StartCap,
   PdfAnnotationLineEndingStyle EndCap,
   bool ShowContent,
   float LineWidth,
   PdfAnnotationBorderStyle LineStyle,
   float LineDashOn,
   float LineDashOff,
   float Opacity,
   byte Red,
   byte Green,
   byte Blue
) 
public:
int AddLineAnnotation( 
   float StartX,
   float StartY,
   float DstX,
   float DstY,
   String^ Title,
   String^ Contents,
   PdfAnnotationLineEndingStyle StartCap,
   PdfAnnotationLineEndingStyle EndCap,
   bool ShowContent,
   float LineWidth,
   PdfAnnotationBorderStyle LineStyle,
   float LineDashOn,
   float LineDashOff,
   float Opacity,
   byte Red,
   byte Green,
   byte Blue
) 

Parameters

StartX
The horizontal (X) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
StartY
The vertical (Y) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
DstX
The horizontal (X) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
DstY
The vertical (Y) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Title
The title of the newly added annotation object, by convention it represents the author of the annotation.
Contents
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
StartCap
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the starting point when drawing a line.
EndCap
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the ending point when drawing a line.
ShowContent
Set this parameter to true, if you want to display the text specified by the Contents parameter as a caption in the appearance of the line, otherwise set it to false. The text should be rendered in a manner appropriate to the content, taking into account factors such as writing direction. The initial value is false.
LineWidth
The width of the line used to draw the line annotation, expressed in the current units specified by the SetMeasurementUnit method.
LineStyle
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the line annotation.
LineDashOn
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw the line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
LineDashOff
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw the line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
Opacity
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
Red
The amount of red color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
Green
The amount of green color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
Blue
The amount of blue color to be used for the resulting color of the drawn line. Use the value between 0 and 255.

Return Value

The unique annotation index from 0 to GdPicturePDF.GetAnnotationCount-1 related to the currently selected page. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Please always ensure that you have selected the correct page using the GdPicturePDF.SelectPage method before adding a required annotation. Likewise, just to inform you, that the toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new line annotation.

You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the GdPicturePDF.SetMeasurementUnit method according to the current coordinate space defined by the GdPicturePDF.SetOrigin method.

Example
How to create a blue line annotation on a new page of the PDF document.
Dim caption As String = "Example: AddLineAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
   (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    'Please always select the required page before adding an annotation.
    If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
        'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
        Dim annotID As Integer = gdpicturePDF.AddLineAnnotation(5, 5, 10, 5, "GdPicture", "This is a line annotation.",
                                                                 PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond, PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond,
                                                                 True, 0.2F, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0, 0.75F, 0, 0, 255)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
            Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
            Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
            Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
            Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
            If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
            message = message + "    subtype: "
            If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
            If gdpicturePDF.SaveToFile("line.pdf") = GdPictureStatus.OK Then
                message = message + vbCrLf + "The file has been saved."
            Else
                message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
            End If
            MessageBox.Show(message, caption)
        Else
            MessageBox.Show("The AddLineAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLineAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
    (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    //Please always select the required page before adding an annotation.
    if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
    {
        int annotID = gdpicturePDF.AddLineAnnotation(5, 5, 10, 5, "GdPicture", "This is a line annotation.",
                                                      PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond, PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond,
                                                      true, 0.2f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0, 0.75f, 0, 0, 255);
        //Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            string annotType = gdpicturePDF.GetAnnotationType(annotID);
            GdPictureStatus status1 = gdpicturePDF.GetStat();
            string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
            GdPictureStatus status2 = gdpicturePDF.GetStat();
            string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
            if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
            message = message + "    subtype: ";
            if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
            if (gdpicturePDF.SaveToFile("line.pdf") == GdPictureStatus.OK)
                message = message + "\nThe file has been saved.";
            else
                message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
            MessageBox.Show(message, caption);
        }
        else
            MessageBox.Show("The AddLineAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
See Also