Smart Label Printer 120/220/Pro
High Level Application Programming Interface for SLPAPI32.DLL

Revised February 9, 1998

Manual Part Number 22-70032-01

Contents

1. Overview

2. BOOL SlpDrawBarCodeXY(int x, int y,
LPSTR lpText);

3. BOOL SlpDrawTextXY(int x, int y, HFONT hFont,
LPSTR lpText);

4. int SlpGetBarCodeWidth(int handle, LPSTR lpText);

5. int SlpGetLabelHeight(void);

6. int SlpGetLabelWidth(void);

7. int SlpGetTextWidth(HFONT hFont, LPSTR lpText);

8. BOOL SlpDrawBitmap(int x, int y, HBITMAP
hBitmap);

9. BOOL SlpDrawLine(int xStart, int yStart, int xEnd, int yEnd, int thickness);

10. HFONT SlpCreateFont(LPSTR lpName, int nPoints,
int nAttributes);

11. int SlpDeleteFont(HFONT hFont);

12. BOOL SlpNewLabel(void);

13. BOOL SlpPrintLabel(int nCopies);

14. BOOL SlpDrawRectangle(int x, int y, int width,
int height, int thickness);

15. BOOL SlpSetBarCodeStyle(int style, int height);

16. BOOL SlpSetPrinter(int nPrinterType,
LPSTR szPort);

17. BOOL SlpSetLabelType(int nID, BOOL fPortrait);

 

1. Overview

This Application Programming Interface (API) documents the various functions included in the Smart Label Printer Sample Code.

2. BOOL SlpDrawBarCodeXY(int x, int y, LPSTR lpText);

Parameters

x Specifies the physical x-coordinate of the starting location where the string will be drawn.

y Specifies the physical y-coordinate of the starting location where the string will be drawn.

lpText Points to the character string to be drawn at the current cursor position.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function draws a character string at the specified cursor position using the current bar code symbology. The function will fail if the string contains any invalid characters or if the bar code symbol will not fit at the current cursor position. The bar code symbology is set by the SetBarCodeStyle function.

The current cursor position will be used for coordinate parameters that are set to zero. For example, the following code:

DrawBarCodeXY(20, 0, "2345");

would change the x-coordinate to 20 and leave the current y-coordinate unchanged. After the bar code symbol is drawn, the cursor is set to the position immediately after the symbol.

If x is negative, the actual x-coordinate will be automatically calculated to center the text horizontally on the label. For example:

DrawBarCodeXY(-1, 1, "2345");

would center the bar code symbol between the left and right margins.

3. BOOL SlpDrawTextXY(int x, int y, HFONT hFont, LPSTR lpText);

Parameters

x Specifies the physical x-coordinate of the starting location where the string will be drawn.

y Specifies the physical y-coordinate of the starting location where the string will be drawn.

hFont Specifies the font to be used for drawing the text. If font is zero, the last selected font is used.

lpText Points to the character string to be drawn.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function draws a character string at the specified cursor position, using the specified font. The function will fail if the string contains any invalid characters or if the string will not fit at the specified cursor position.

The hFont parameter should be a handle obtained from a call to the SlpCreateFont function, or any valid Windows font handle. The current cursor position will be used for coordinate parameters that are set to zero. For example, the following code:

DrawTextXY(20, 0, 1, "text");

would change the x-coordinate to 20 and leave the current y-coordinate unchanged. After the text is drawn, the cursor is set to the position immediately after the last character drawn.

If x is negative, the actual x-coordinate will be automatically calculated to center the text horizontally on the label. For example:

DrawTextXY(-1, 0, 1, "text");

would center the word, "text" between the left and right margins.

4. int SlpGetBarCodeWidth(int handle, LPSTR lpText);

Parameters

handle Points to the barcode object.

lpText Points to the character string to be measured.

Return Value

Returns the width (in pixels) of text when drawn as a bar code, using the current symbology. If the function fails, the return value is 0.

Remarks

This function calculates the width of a bar code symbol. The calculated width is based on the bar code symbology set by the SetBarCodeStyle function. The function will fail if the string contains any invalid characters.

5. int SlpGetLabelHeight(void);

Parameters

None

Return Value

Returns the height of the label, in pixels.

 

6. int SlpGetLabelWidth(void);

Parameters

None

Return Value

Returns the width of the label, in pixels.

7. int SlpGetTextWidth(HFONT hFont, LPSTR lpText);

Parameters

hFont Specifies the font to be used for measuring the text. If font is zero, the last selected font is used.

lpText Points to the character string to be measured.

Return Value

Returns the width (in pixels) of text when drawn in the currently selected font. If the function fails, the return value is 0.

Remarks

This function computes the width of a character string using the specified font. The function will fail if the string contains any invalid characters.

 

8. BOOL SlpDrawBitmap(int x, int y, HBITMAP hBitmap);

Parameters

x Specifies the physical x-coordinate of the upper-left corner of the image.

y Specifies the physical y-coordinate of the upper-left corner of the image.

hBitmap Handle of the bitmap image.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function draws a bitmap image at the specified position on the current label.

9. BOOL SlpDrawLine(int xStart, int yStart, int xEnd, int yEnd, int thickness);

Parameters

xStart Specifies the physical x-coordinate of the starting point of the line.

yStart Specifies the physical y-coordinate of the starting point of the line.

xEnd Specifies the physical x-coordinate of the ending point of the line.

yEnd Specifies the physical y-coordinate of the ending point of the line.

thickness Specifies the thickness of the line, in pixels. Must be in the range 1 to 8.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function draws a line from the specified start point up to, but not including, the end point. The function will fail if the line will not fit (either too long or too thick) at the specified position or if thickness is out of range.

For example, the following code:

SlpDrawLine(20, 20, 100, 100, 4);

will draw a diagonal line 80 pixels long and 4 pixels thick.

10. HFONT SlpCreateFont(LPSTR lpName, int nPoints, int nAttributes);

Parameters

lpName Name of the typeface

nPoints Height of font, in points

nAttributes Attributes for the font. See below.

Return Value

If successful, the function returns a handle to the font, otherwise the return value is 0.

The nAttribute parameter may be one or more of the following values (defined in SLPAPI.H):

NORMAL BOLD ITALIC UNDERLINE

For example, to create a font with both Bold and Italic attributes, the nAttributes parameter would be BOLD | ITALIC.

Remarks

This function creates a font with the specified typeface and attributes. The returned handle is used to specify the font when using the text drawing functions. When the font is no longer needed, the SlpDeleteFont function should be called to release memory used by the font.

11. int SlpDeleteFont(HFONT hFont);

Parameters

hFont Handle of font to be deleted.

Return Value

The function returns TRUE if successful or FALSE if hFont is invalid.

Remarks

This function deletes a font and frees memory allocated for it.

12. BOOL SlpNewLabel(void);

Parameters

None

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function starts a new label and clears the label buffer. It must be called before "drawing" a label.

13. BOOL SlpPrintLabel(int nCopies);

Parameters

nCopies Specifies the number of copies (of the current label) to print.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function causes the current label to be printed. It should be called after all calls to the drawing functions (DrawTextXY, DrawBarCodeXY, etc.) have been completed.

14. BOOL SlpDrawRectangle(int x, int y, int width, int height, int thickness);

Parameters

x Specifies the physical x-coordinate where the left side of the rectangle will be drawn.

y Specifies the physical y-coordinate where the top of the rectangle will be drawn.

width Specifies the width of the rectangle, in pixels.

height Specifies the height of the rectangle, in pixels.

thickness Specifies the thickness of the lines, in pixels. Must be in the range 1 to 8.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function draws a rectangle at the specified position. The function will fail if the rectangle will not fit (either too wide or too high) at the specified position or if thickness is out of range.

 

For example, the following code:

Rectangle(20, 20, 100, 50, 4);

will draw a rectangle 100 pixels wide and 50 pixels high, using lines which are 4 pixels thick.

15. BOOL SlpSetBarCodeStyle(int style, int height);

Parameters

style Specifies the symbology and dimensions to be used for drawing bar codes. See table below for valid values.

height Specifies the height (in points) of the bars.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function is used to select the bar code symbology and size to be used for drawing bar code symbols. The function will fail if style is not a valid value from the table below.

The height parameter sets the height (in points) of the bars to be used when drawing the bar code. The style parameter must be one of the following values:

style

Symbology

Smallest Bar Width

Bar Ratio

1

Code 39

0.250 mm

1 : 2.0

2

Code 39

0.250 mm

1 : 2.5

3

Code 39

0.250 mm

1 : 3.0

4

Code 39

0.375 mm

1 : 2.0

5

Code 39

0.375 mm

1 : 2.3

6

Code 39

0.375 mm

1 : 2.6

7

Code 39

0.375 mm

1 : 3.0

10

Code 128

0.250 mm

*

11

Code 128

0.375 mm

*

12

Code 128

0.500 mm

*

13

POSTNET**

N/A

N/A

*Bar ratios are not adjustable for Code 128 bar codes.

**POSTNET bars have a fixed size and ratio

 

16. BOOL SlpSetPrinter(int nPrinterType, LPSTR szPort);

Parameters

nPrinterType Specifies the target printer type.

szPort The name of the port that the printer is connected to (e.g., "COM1", "COM2", etc.).

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function is used to specify the model and port of the target printer. nPrinterType may be one of the following values (defined in SLPAPIW.H):

SLP_PRO SLP_120 SLP_220

17. BOOL SlpSetLabelType(int nID, BOOL fPortrait);

Parameters

nID Specifies the desired label type identifier (see below).

fPortrait Set TRUE for portrait orientation, FALSE for landscape.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

Remarks

This function is used to specify the target label type. The nID parameter must be one of the following values:

nID

Description

Size (inches)

1

Standard Address

1.1 x 3.5

2

Shipping

2.15 x 4.0

3

Diskette

2.15 x 2.75

4

Large Address

1.4 x 3.5

5

Multi-Purpose

1.5 x 2.0

7

VHS Spine

0.75 x 5.8

8

VHS Face

1.8 x 3.05

9

8mm Spine

0.4 x 2.85

10

File Folder

0.55 x 3.45

11

35mm Slide

0.45 x 1.5

12

Name Badge

2.15 x 2.75