Barcode .Net Class Library

Draw Method (3)

Applies To: Barcode | BarcodeControl | BarcodeImage

Draws a barcode to a Graphics object. This is the most flexible of all three versions the Draw method.

[Visual Basic]
Public Sub Draw( _
   ByVal g As Graphics, _
   ByVal rect As RectangleF, _
   ByVal unit As GraphicsUnit, _
   ByVal scale As float, _
   ByVal orientation As BarcodeOrientation, _
   ByVal font As Font, _
   ByVal clrFore As Color, _
   ByVal clrBack As Color, _
   ByVal flags As BarcodeDrawFlags, _
   ByVal textOnlyString As String _
)

[C#]
public void Draw(
   Graphics g, 
   RectangleF rect, 
   GraphicsUnit unit, 
   float scale, 
   BarcodeOrientation orientation, 
   Font font, 
   Color clrFore, 
   Color clrBack, 
   BarcodeDrawFlags flags, 
   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.
orientation
A BarcodeOrientation enumeration specifying the orientation of the barcode; this overrides the Orientation property.
font
Font used to draw the barcode caption(s); this overrides the Font property.
clrFore
Color used to draw the barcode bars and caption(s); this overrides the ForeColor property.
clrBack
Color used to draw the barcode background; this overrides the BackColor property.
flags
A BarcodeDrawFlags enumeration specifying how the barcode is to be drawn. You can use DrawFlagsFromProperties for the current or DefaultDrawFlags for the default value of this parameter. Properties that have corresponding BarcodeDrawFlags members will have their values overriden by this parameter for the duration of this Draw method call, as shown below,
Overriden Property Name BarcodeDrawFlags Member
AddOnTextPosition AddOnTextAtTop, AddOnTextAtBottom, HideAddOnText
HorizontalAlignment Left, Center, Right
PixelAligned NotPixelAligned
RetainAspectRatio RetainAspectRatio
ShowCode39StartStop ShowCode39StartStop
StretchText NoStretchText
TextPosition MainTextAtTop, MainTextAtBottom, HideMainText
UniBarHeight UniBarHeight
UpcSmallFont NoUpcSmallFont
VerticalAlignment Top, Middle, Bottom
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 (2)


© 2002 Bokai Corporation. All rights reserved.