Label Functions
ddoc Print and Preview Mailing Label API
ddoc contains a very easy to use mailing label generator. It frees the programmer from having to worry about the specifics of printing mailing labels. ddoc reads a template for the mailing labels (description of rows and columns that make up a label) from an .ini file. The programmer needs to indicate which template to use (e.g. Avery5260) and the engine handles the details. After telling ddoc which template to use, the programmer simply makes calls to print lines on a label (Using dpLabelText). After finishing printing on the first label, s/he just calls dpNextLabel to go to the next label. The engine keeps track of where each line needs to be printed and even creates the next page for the programmer. Ddoc only comes with a couple of predefined labels in ddocml.ini, but you are free to edit this file and define as many mailing labels as you wish. If you would like to share your label definitions with others, please email them to me as I will be adding them to the default ddocml.ini file and posting it on my web-site. Thanks for your help in this area as I just don't have time to sit down and define all of the mailing labels that Avery makes!

dpLabelLines

Declare Function dpLabelLines Lib "ddoc16.dll" _
   ( ByVal iHandle% ) As Integer

This function returns the number of lines that fit on a single label in the currently selected label template.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc

Return Value Description
Integer Indicates the number of lines that can be printed under the current label definition.

dpLabelsPerPage

Declare Function dpLabelsPerPage Lib "ddoc16.dll" _
   ( ByVal iHandle% ) As Integer

This function returns the number of labels that fit on a page for the currently selected label template.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc

Return Value Description
Integer Indicates the number of labels that can be printed under the current label definition.

dpLabelText

Declare Sub dpLabelText Lib "ddoc16.dll" _
   ( ByVal iHandle%, ByVal szLabelLine$ )

This function prints a line of text on the current label. The mailing label engine knows exactly where to put the text on the label.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
szLabelLine$ The text to print on the label. It will print on the current label and the current line as maintained by the label engine.

dpLabelX

Declare Sub dpLabelX Lib "ddoc16.dll" _
   ( ByVal iHandle%, sngX As Single )

This function fills the sngX variable with the X coordinate of the upper-left hand corner of the current label. This function can be used if you want to print on a label (a logo for instance) without using the dpLabelText function.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
sngX This variable is filled with the x-coordinate of the upper-left corner of the current label.

dpLabelY

Declare Sub dpLabelY Lib "ddoc16.dll" _
   ( ByVal iHandle%, sngY As Single )

This function fills the sngY variable with the Y coordinate of the upper-left hand corner of the current label.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
sngY This variable is filled with the y-coordinate of the upper-left corner of the current label.

dpMailInit

Declare Function dpMailInit Lib "ddoc16.dll" _
   ( ByVal iHandle As Integer, ByVal szIniFile$, _
     ByVal szIniSection$, ByVal nAlign%  ) _
     As Integer

This function tells the ddoc engine which label template you wish to use. You need to tell it the file where the label definition is contained (usually ddocml.ini) , the section in the file where the label definition is (e.g. "Avery5260"), and how to align the label text (DDOC_CENTER, DDOC_LEFT, etc.)

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
szIniFile The name of the file containing the label definition. Usually ddocml.ini
szIniSection The section in the definition file for the label that you want to print (e.g. Avery5260)
nAlign How you want the label text aligned on the label. This will be either DDOC_LEFT or DDOC_CENTER.

Return Value Description
DDOC_MAIL_* One of the defined mailing label return constants. If you get one of these either the .ini file doesn't exist, the section isn't valid, or a key in the section doesn't have a valid value. See the constant definitions for details.
0 Success

dpNextLabel

Declare Sub dpNextLabel Lib "ddoc16.dll" _
   ( ByVal iHandle% )

This function tells the engine that you want to skip to the next label. The engine moves its internal position pointers appropriately and creates new pages as needed. In actuality, there may be instances where you don't need to call this at all. Ddoc will call it for you if you have exceeded the number of lines that fit on a label. Suppose you have a label that holds 6 lines of text. After you have added 6 lines to this label and you call a 7th line, ddoc will call dpNextLabel automatically for you.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc

dpPrintTemplate

Declare Sub dpPrintTemplate Lib "ddoc16.dll" _
   ( ByVal iHandle%, ByVal LabAlign% )

dpPrintTemplate is a wrapper function that prints out what the currently label definition looks like when printed. It can be used in your applications to give the user an idea of what each available label description looks like.

Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
LabAlign How to align the text on the labels when printing the template. Usually DDOC_LEFT or DDOC_CENTER.

dpSetLabel

Declare Sub dpSetLabel Lib "ddoc16.dll" _ 
   ( ByVal iHandle%, ByVal nLabelNumber% )

This routine tells the engine to print the next label on a specific label number. Labels are numbered vertically on the page. For example, Avery5260 labels have 3 columns of 10 labels each - total 30 labels on the page. Label number 1 is in the upper-left hand corner, label #10 is in the lower-left, label 11 is in the top-middle, label 20 is in the bottom/middle, label 21 is in the upper-right, and label 30 is in the bottom-right. If you would like to start printing on the second column of labels, you call:

dpSetLabel iHandle%, 11
Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
nLabelNumber The number of the label to skip to.

dpSetLabelLine

Declare Sub dpSetLabelLine Lib "ddoc16.dll" _
   ( ByVal iHandle%, ByVal nLabelLine% )

This routine tells the label engine on which line in the current label you would like to start printing. For example, if you want to start printing on the 2nd line, call:

dpSetLabelLine iHandle%, 2
Parameter Description
iHandle% Handle to the document as returned by dpStartDoc
nLabelLine Sets the next line to print on in the current label.