Barcode .Net Class Library

Draw Method (2)

Draws a barcode to a Graphics object. This is more flexible than Draw (1) but less flexible than Draw(3). Applies to Barcode, BarcodeControl or BarcodeImage.

[Visual Basic]
Public Sub Draw( _
   ByVal g As Graphics, _
   ByVal rect As RectangleF, _
   ByVal unit As GraphicsUnit, _
   ByVal scale As float, _
   ByVal extraFlags As BarcodeDrawFlags, _
   ByVal textOnlyString As String _
)

[C#]
public void Draw(
   Graphics g, 
   RectangleF rect, 
   GraphicsUnit unit, 
   float scale, 
   BarcodeDrawFlags extraFlags, 
   string textOnlyString
);

Parameters

g
Graphics object to which the barcode is to be drawn.
rect
Location and size of the barcode, in units given by unit and scaled by scale. rect.width may be either that of the narrowest bar of the barcode or that the entire barcode, depending on whether the BarcodeDrawflags.WidthPerModule bit is set in the extraFlags parameter.
unit
A System.Drawing.GraphicsUnit enumeration that specifies the unit used by rect and is scaled by scale.
ValueMeaning
DisplaySpecifies 1/75 inch as the unit of measure.
DocumentSpecifies the document unit (1/300 inch) as the unit of measure.
InchSpecifies the inch as the unit of measure.
MillimeterSpecifies the millimeter as the unit of measure.
PixelSpecifies a device pixel as the unit of measure.
PointSpecifies a printer's point (1/72 inch) as the unit of measure.
WorldSpecifies the world unit as the unit of measure.

If World is specified, then the current PageUnit of g will be used and scale ignored.

scale
Specifies how unit is to be scaled. Ignored if World is specified for unit.
extraFlags
A BarcodeDrawFlags enumeration specifying how the barcode is to be drawn, complementing the current property settings. Only the subset of the BarcodeDrawFlags members (cf. table below) that have no corresponding properties can be used and will be effective.
Member Name Description
NoDrawBackground Do not draw the background.
CalculateSizeOnly Do not actually draw the barcode; calculate the barcode position and size only.
Clip Clip the barcode to the target rectangle.
PaintWholeRect Paint the background of the entire target rectangle even if the actual barcode will only take up part of it.
DrawTextOnly Draw only the barcode data, not the barcode.
DrawBackgroundOnly Draw only the background, not the barcode.
WidthPerModule Indicates that the width parameter specifies the width of the thinnest barcode bar rather than that of the barcode.
NoRestoreGraphicsState Do not restore the state of the Graphics object after drawing.
textOnlyString
If not null, only this string will be drawn instead of a barcode image.

Remarks

Both unit and scale together specify the real unit for the rect parameter. This is true for general .Net graphics and GDI+ programming as well. For example, GraphicsUnit.Inch for unit and 0.01 for scale would specify the unit of measure of 0.01 inch (or LOENGLISH). Note that the real unit has to be small enough; you would not get the expected result by using scale=1 and compensatingly scaled-down numbers for rect.

See Also

Draw (1) | Draw (3)


© 2002 Bokai Corporation. All rights reserved.