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 As Barcode1DWriterType, _
ByVal As String, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Color _
) As GdPictureStatus
public GdPictureStatus DrawBarcode1D(
Barcode1DWriterType ,
string ,
float ,
float ,
float ,
float ,
Color
)
public function DrawBarcode1D(
: Barcode1DWriterType;
: String;
: Single;
: Single;
: Single;
: Single;
: Color
): GdPictureStatus;
public function DrawBarcode1D(
: Barcode1DWriterType,
: String,
: float,
: float,
: float,
: float,
: Color
) : GdPictureStatus;
public: GdPictureStatus DrawBarcode1D(
Barcode1DWriterType ,
string* ,
float ,
float ,
float ,
float ,
Color
)
public:
GdPictureStatus DrawBarcode1D(
Barcode1DWriterType ,
String^ ,
float ,
float ,
float ,
float ,
Color
)
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.
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();
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
Reference
GdPicturePDF Class
GdPicturePDF Members
Overload List
GetMeasurementUnit Method
SetMeasurementUnit Method
SetMeasurementUnit Method
SetOrigin Method
GetMeasurementUnit Method
GetOrigin Method
DrawBarcodeAztec(String,BarcodeAztecCodeVersion,Int32,Int32,Int32,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeDataMatrix(String,BarcodeDataMatrixEncodingMode,BarcodeDataMatrixVersion,Int32,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeMicroMicroQrCode(String,BarcodeQREncodingMode,BarcodeMicroQRErrorCorrectionLevel,Int32,Int32,Single,Single,Color) Method
DrawBarcodePDF417(String,BarcodePDF417EncodingMode,BarcodePDF417ErrorCorrectionLevel,Int32,Int32,Int32,Int32,Single,Single,Byte,Byte,Byte) Method
DrawBarcodeQrCode(String,BarcodeQREncodingMode,BarcodeQRErrorCorrectionLevel,Int32,Int32,Single,Single,Color) Method