Home > BSPrinter documentation > Reference

PrintEx Method

Applies to: PrintPreview, IPrinterEx object

  Return Type:     None.  
 
  Parameter(s):  
   In     Optional     Text     As     Variant  
   In     Optional     Options     As     BSPrintExOptionsConstants     Default value: bsLineFeed (0)  
   In     Optional     X     As     Variant  
   In     Optional     Y     As     Variant  
   In     Optional     Width     As     Variant  
   In     Optional     Height     As     Variant  
   In     Optional     Alignment     As     BSAlignmentConstants     Default value: bsAlignLeftTop (0)  
   In     Optional     WordWrap     As     Boolean     Default value: True  
   In     Optional     WordBreak     As     Boolean     Default value: False  
   In     Optional     RightToLeftReading     As     BSAutoYesNoConstants     Default value: bsAutoYN (2)  
   In     Optional     RectMarginsX     As     Single     Default value: 0  
   In     Optional     RectMarginsY     As     Single     Default value: 0  
   In     Optional     CancelIfTextExceedsWidth     As     Boolean     Default value: False  
   In/Out     Optional     TextExceedsWidth     As     Boolean  
   In/Out     Optional     StartsNewPage     As     Boolean  


Description:

Like the Printer.Print method, it allows to print text but with some additional options.

Parameters explained:

Text: the text to be printed

Options: can be any of these values:
bsLineFeed = 0
bsNoLineFeed = 1
bsAddTab = 2
The default for this optional parameter is bsLineFeed, that means that like the original Printer.Print method, it will add a line feed automatically after the text.
On the contrary, if this parameter is set to bsNoLineFeed, then no line feed will be added. It is like the function of the semicolon (;) in the original Printer.Print method.
bsAddTab adds a Tab after the text, just like the comma (,) in the Printer.Print method.

X, Y, Width and Height: These parameters can define the rectangle on the page where the text will be printed. If they are omitted, the Printer.CurrentX and Printer.CurrentY will be used for the position, and the rectangle is the available space on the page. The text can wrap to fit in the rectangle.

Alignment: Sets the alignment of the text in the available space. If the rectangle was set by the X, Y, Width and Height arguments, the text will be aligned in that rectangle according to the setting of this parameter.
Possible values are:
bsAlignLeftTop = 0
bsAlignLeftCenter = 1
bsAlignLeftBottom = 2
bsAlignCenterTop = 3
bsAlignCenterCenter = 4
bsAlignCenterBottom = 5
bsAlignRightTop = 6
bsAlignRightCenter = 7
bsAlignRightBottom = 8
The default setting for this parameter is bsAlignLeftTop

WordWrap: determines whether the text will wrap into another line if it is too long to fit the available horizontal space.
The default setting for this parameter is True.
Note: This is one of the main advantages over the original Printer.Print method.

WordBreak: similar to WordWrap, but in this case it determines whether the words can be split into more than one line when the text doesn't fit into the available horizontal space.
The default setting for this parameter is False.
Note: the difference between WordWrap and WordBreak, is that WordWrap does not split words. WordBreak implies WordWrap.

RightToLeftReading: Sets the text direction right-to-left or left-to-right without changing the RightToLeft property setting.
If set to bsAutoYN (default setting), the RightToLeft property setting is used instead to set the text direction.
Note: True is converted to bsYes

RectMarginsX, RectMarginsY:
These values can define margins within the rectangle set by the parameters X, Y, Width and Height; therefore, they affect the position of the text that is according to the Alignment parameter.
They must be in the current ScaleMode of the Printer.

CancelIfTextExceedsWidth:
Determines whether the printing operation will be aborted if the horizontal space is smaller than required.
The default setting for this parameter is False.

TextExceedsWidth: This Boolean parameter needs to be passed by reference and is a return value. Returns True if the required horizontal space is greater than the available space.

StartsNewPage: This Boolean parameter needs to be passed by reference and is a return value. Returns True if this print operation starts a new page.

See Also:

TextWidthEx method
TextHeightEx method