GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / DrawBarcode1D Method / DrawBarcode1D(Barcode1DWriterType,String,Single,Single,Single,Single,Color) Method
A member of the Barcode1DWriterType enumeration. The type of the required barcode.
The data to encode using the required barcode.
The horizontal (X) coordinate of the destination 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 destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The width of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
A color object that defines the color to be used for drawing a required barcode.
Example





In This Topic
DrawBarcode1D(Barcode1DWriterType,String,Single,Single,Single,Single,Color) Method
In This Topic
Draws a required 1D barcode onto the currently selected page of the loaded PDF document according to your preference.

This method uses the RGB color space internally when manipulating with the barcode's color you have specified.

The coordinates and the dimensions of the specified barcode need to be set in the current units with respect to the currently located origin defined in the PDF document, related to the actual page, where the barcode is to be drawn. You can use the GetMeasurementUnit method to determine the currently defined units and you can use the SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Overloads Function DrawBarcode1D( _
   ByVal BarcodeType As Barcode1DWriterType, _
   ByVal Data As String, _
   ByVal DstX As Single, _
   ByVal DstY As Single, _
   ByVal DstWidth As Single, _
   ByVal DstHeight As Single, _
   ByVal BarColor As Color _
) As GdPictureStatus
public GdPictureStatus DrawBarcode1D( 
   Barcode1DWriterType BarcodeType,
   string Data,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight,
   Color BarColor
)
public function DrawBarcode1D( 
    BarcodeType: Barcode1DWriterType;
    Data: String;
    DstX: Single;
    DstY: Single;
    DstWidth: Single;
    DstHeight: Single;
    BarColor: Color
): GdPictureStatus; 
public function DrawBarcode1D( 
   BarcodeType : Barcode1DWriterType,
   Data : String,
   DstX : float,
   DstY : float,
   DstWidth : float,
   DstHeight : float,
   BarColor : Color
) : GdPictureStatus;
public: GdPictureStatus DrawBarcode1D( 
   Barcode1DWriterType BarcodeType,
   string* Data,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight,
   Color BarColor
) 
public:
GdPictureStatus DrawBarcode1D( 
   Barcode1DWriterType BarcodeType,
   String^ Data,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight,
   Color BarColor
) 

Parameters

BarcodeType
A member of the Barcode1DWriterType enumeration. The type of the required barcode.
Data
The data to encode using the required barcode.
DstX
The horizontal (X) coordinate of the destination 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 destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
DstWidth
The width of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
DstHeight
The height of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
BarColor
A color object that defines the color to be used for drawing a required barcode.

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
This method is only allowed for use with non-encrypted documents.
Example
How to draw a 1-dimensional barcode onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcode1D"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
    If status = GdPictureStatus.OK Then
        If (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, Color.Red) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, Color.Red) = GdPictureStatus.OK) Then
            status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.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 one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcode1D";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
    if (status == GdPictureStatus.OK)
    {
       if ((gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, Color.Red) == GdPictureStatus.OK) &&
           (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, Color.Red) == GdPictureStatus.OK))
        {
            status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.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 one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also