Returns the horizontal width and vertical height of a rotated barcode symbol in logical dots or pixels. The barcode symbol is specified in the parameters of this method.
type
{ Defined in the pCore1D unit }
TDisplayText = (dtNone, dtBarcode, dtFullEncoded);
{ Defined in the pCore1D unit }
TTextAlignment = (taLeft, taCenter, taRight, taJustify, taLeftQuietZone, taCenterQuietZone, taRightQuietZone, taJustifyQuietZone, taCustom);
function DrawToSize(var TotalWidth, TotalHeight, SymbolWidth, SymbolHeight: Integer; Canvas: TCanvas; Data: AnsiString; AutoCheckDigit: Boolean; BarcodeTextDefine: TBarcodeTextDefine; Ratio: Double; Module: Integer = 0; Height: Integer = 0; Angle: Integer = 0; HDPI: Integer = 0; VDPI: Integer = 0): Integer; overload; virtual;
The method returns the horizontal width and vertical height of the rotated barcode symbol that is specified by parameters of this method, in logical dots or pixels.
TotalWidth: Integer; Returns the horizontal width of the rotated barcode symbol in logical dots or pixels in the horizontal direction.
Before rotation, if the human readable text is represented, both the width of human readable text and the height of the human readable text (including its vertical spacing) will be consulted. Otherwise, they will not be consulted. Note, if the human readable text is represented and it exceeds the barcode symbol in horizontal or vertical direction, the excess is included.
For TBarcode1D_UPCA, TBarcode1D_UPCE, TBarcode1D_UPCE0, TBarcode1D_UPCE1, TBarcode1D_EAN2, TBarcode1D_EAN5, TBarcode1D_EAN8, and TBarcode1D_EAN13 barcode components, if the human readable text is represented, and the TextAlignment field of the BarcodeTextDefine parameter is set to taCustom, the width of quiet zone marks and their horizontal spacing (LeftQuietZoneSpacing and RightQuietZoneSpacing) are included too.
For TBarcode1D_ITF6, TBarcode1D_ITF14, and TBarcode1D_ITF16 barcode components, the width of left and right bearer bars (BearerWidth), the height of top and bottom bearer bars (BearerWidth), the left spacing, and the right spacing are included too.
TotalHeight: Integer; Returns the vertical height of the rotated barcode symbol in logical dots or pixels in the vertical direction.
Before rotation, if the human readable text is represented, both the width of human readable text and the height of the human readable text (including its vertical spacing) will be consulted. Otherwise, they will not be consulted. Note, if the human readable text is represented and it exceeds the barcode symbol in horizontal or vertical direction, the excess is included.
For TBarcode1D_UPCA, TBarcode1D_UPCE, TBarcode1D_UPCE0, TBarcode1D_UPCE1, TBarcode1D_EAN2, TBarcode1D_EAN5, TBarcode1D_EAN8, and TBarcode1D_EAN13 barcode components, if the human readable text is represented, and the TextAlignment field of the BarcodeTextDefine parameter is set to taCustom, the width of quiet zone marks and their horizontal spacing (LeftQuietZoneSpacing and RightQuietZoneSpacing) are included too.
For TBarcode1D_ITF6, TBarcode1D_ITF14, and TBarcode1D_ITF16 barcode components, the width of left and right bearer bars (BearerWidth), the height of top and bottom bearer bars (BearerWidth), the left spacing, and the right spacing are included too.
SymbolWidth: Integer; Returns the distance between the leading and trailing of the rotated barcode symbol in logical dots or pixels in the horizontal direction.
Before rotation, if the human readable text is represented, the width of human readable text will be consulted. Otherwise, it will not be consulted. Note, if the human readable text is represented, and it exceeds the barcode symbol in horizontal direction, the excess is included.
For TBarcode1D_UPCA, TBarcode1D_UPCE, TBarcode1D_UPCE0, TBarcode1D_UPCE1, TBarcode1D_EAN2, TBarcode1D_EAN5, TBarcode1D_EAN8, and TBarcode1D_EAN13 barcode components, if the human readable text is represented, and the TextAlignment field of the BarcodeTextDefine parameter is set to taCustom, the width of quiet zone marks and their horizontal spacing (LeftQuietZoneSpacing and RightQuietZoneSpacing) are included too.
For TBarcode1D_ITF6, TBarcode1D_ITF14, and TBarcode1D_ITF16 barcode components, the width of left and right bearer bars (BearerWidth), the left spacing, and the right spacing are included too.
SymbolHeight: Integer; Returns the distance between the top and bottom of the rotated barcode symbol in logical dots or pixels in the vertical direction.
Before rotation, if the human readable text is represented, the height of the human readable text and its vertical spacing (TextVSpacing) are included. If it exceeds the barcode symbol in vertical direction, the excess is included too.
For TBarcode1D_ITF6, TBarcode1D_ITF14, and TBarcode1D_ITF16 barcode components, the height of top and bottom bearer bars (BearerWidth) are included too.
See also the "Height" property.
Canvas: TCanvas; Specifies target canvas that the barcode symbol will be represented in it. If the DisplayText property isn't set to dtNone, the parameter is required in order to calculate the width of human readable text. Otherwise, it will be ignored, so you can set it to nil.
Data: AnsiString; Specifies the barcode text. It is of type AnsiString, so you can specifiy the barcode text in AnsiString format. The method is available only for the Delphi/C++ Builder 2009 or later.
For the TBarcode1D_Code128 and the TBarcode1D_EAN128 components, you can use the method if you encode a block of binary (bytes) data under Delphi/C++ Builder 2009 or later. If you encode a block of binary (bytes) data into a barcode symbol under Delphi/C++ Builder 2007 or early, please use the DrawToSize (Syntax 2) overloading method. Note, the "\" character is used as a escape prefix, so if you want to encode the "\" character, please use the "\\" instead of it.
For the TBarcode1D_OneCode component, first 20 characters are the Tracking (It is right padded with zeroes to 20 characters), then come the Routing.
For the TBarcode1D_FIM component, it is single character that denotes the FIM type, form "A" to "E", the "E" character dnotes an empty barcode symbol.
For the TBarcode1D_Patch component, it is single character that denotes the Ptach type, and it can be set to "0", "1", "2", "3", "4", "6", and "T", the "0" character dnotes an empty barcode symbol.
For the TBarcode1D_Code32 component, First "A" character does not need to be entered in the parameter. Also, for the TBarcode1D_PZN component, First "PZN" characters do not need to be entered in the parameter.
See also the "Data" property.
AutoCheckDigit: Boolean; Specifies whether the check digit should be automatically appended to the barcode symbol.
See also the "AutoCheckDigit" property.
BarcodeTextDefine: TBarcodeTextDefine; Specifies whether to display the human readable text and how to display the human readable text. The record is defined in the pBarcode1D unit.
See also the TBarcodeTextDefine record.
Ratio: Double; Specifies ratio between a wide bar (or space) and a narrow bar (or space) in the barcode symbol. The normal values are from 2.0 to 3.0. If the parameter is less than or equal to zero, the method fails, and the return value is -2.
See also the "Ratio" property.
Module: Integer; Specifies the module width in logical dots or pixels in the horizontal direction, it is the width of the smallest bar (or space) in the barcode symbol. If the parameter isn't provided or it is set to zero, the value of "Module" property will be used.
See also the "Module" property.
Height: Integer; Specifies the distance between the top and bottom of a barcode symbol in modules. If the human readable text is displayed, the height of the human readable text and its vertical spacing (TextVSpacing) are included.
If the parameter isn't provided or its value is set to zero, the value of Height property will be used.
For TBarcode1D_ITF6, TBarcode1D_ITF14, and TBarcode1D_ITF16 barcode components, the height of the top and bottom bearer bars (BearerWidth) are included too.
If the human readable text is displayed, and it exceeds the barcode symbol in vertical direction, the excess isn't included.
See also the "Height" property.
Note: If the parameter is less than zero, its absolute value specifies the height in logical dots or pixels in the vertical direction.
Angle: Integer; Specifies an angle in degrees to rotate the barcode symbol. It defaults to 0 if the Angle is not provided, meaning left to right horizontal direction.
HDPI: Integer, Specifies the horizontal resolution of canvas in logical DPI. It's the number of logical dots or pixels per inch.
It defaults to 0 if the HDPI is not provided. If it is set to less than or equal to zero, the physical horizontal resolution obtained from the Canvas parameter will be used. So if you use the MM_TEXT map mode, you can specify it to 0. If you use the MM_ISOTROPIC or MM_ANISOTROPIC map mode, and the horizontal units or scaling is changed, the parameter is required in order to obtain the correct sizes when the symbol is rotated.
When the Canvas parameter is set to nil, if both HDPI and VDPI are set to 0, it indicates the horizontal resolution is equal to the vertical resolution.
VDPI: Integer, Specifies the vertical resolution of canvas in logical DPI. It's the number of logical dots or pixels per inch.
It defaults to 0 if the VDPI is not provided. If it is set to less than or equal to zero, the physical vertical resolution obtained from the Canvas parameter will be used. So if you use the MM_TEXT map mode, you can specify it to 0. If you use the MM_ISOTROPIC or MM_ANISOTROPIC map mode, and the vertical units or scaling is changed, the parameter is required in order to obtain the correct sizes when the symbol is rotated.
When the Canvas parameter is set to nil, if both HDPI and VDPI are set to 0, it indicates the horizontal resolution is equal to the vertical resolution.
See diagram:
The overloading method is available only for the Delphi/C++ Builder 2009 or later.