Barcode.DrawCustom
void TECIT.TBarCode.Barcode.DrawCustom(float width, float height)
Parameters
| Parameter / type | Description |
|---|---|
width float |
The width in mm. |
height float |
The height in mm. |
Event handler methods for DrawRow, DrawBar, DrawText can look like this:
public void OnDrawRow(object sender, CustomDrawingEventArgs e)
{
// This method is called once by DrawCustom for each row of the barcode.
}
public void OnDrawBar(object sender, CustomDrawingEventArgs e)
{
// This method is called once by DrawCustom for each bar of the barcode. <br>
// Here you can add your code to draw a single bar.
}
public void OnDrawText(object sender, CustomDrawingEventArgs e)
{
// This method is called by DrawCustom for drawing the human readable text.
// Here you can add your code to draw the human readable text.
}The parameter CustomDrawingEventArgs e will contain the necessary information (element position, width, height, etc.) for custom drawing.
The following excerpt shows how to set the event handler and call DrawCustom:
Barcode b = new Barcode();
// DrawCustom works only if TBarCode is licensed.
b.License("licensee name", LicenseType.DeveloperOrWeb, 1, "license key", TBarCodeProduct.Barcode2D);
// Set barcode type.
b.BarcodeType = BarcodeType.Code128;
// Set barcode data.
b.Data = "Test 123"; <br>
// Set callback methods.
b.DrawText += OnDrawText;
b.DrawRow += OnDrawRow;
b.DrawBar += OnDrawBar; <br>
// Call DrawCustom for custom drawing of a barcode with 50 x 20 mm.
// DrawCustom will call the methods OnDrawText, OnDrawRow, OnDrawBar as required.
b.DrawCustom(50, 20); <br>