|
|
|
|
|
- Origin and physical margins
- Managing the parameter
- Combining positions
- Printing in Java and Android
- Miscellaneous
iYPos (Function) In french: iPosY Allows you to manage the vertical position (Y coordinate) of print cursor in the page. You can: - find out the current vertical position,
- modify the vertical position of print cursor.
Remark: When printing a character string, the current vertical position points to the top of the string to print. The bottom print line depends on the height of the fonts used in the printed line.
// Draw horizontal lines every two millimeters // across the entire page height iHLine(0, iPageWidth(), 1) Â // Draws a line iYPos(iYPos() + 2) Â // Positions the cursor 2 mm lower iHLine(0, iPageWidth(), 3) Â // Draws a second line iEndPrinting() Syntax
Finding out the vertical position of print cursor Hide the details
<Result> = iYPos()
<Result>: Real Current vertical position of cursor (in millimeters).
Modifying the vertical position of print cursor Hide the details
<Result> = iYPos(<Vertical position> [, <Immediate calculation>])
<Result>: Character string Requested vertical position. <Vertical position>: Real New vertical position (Y-coordinate) of print cursor (in millimeters). <Immediate calculation>: Optional boolean - True (by default) to immediately calculate the vertical position.
- False if the vertical position must be calculated during the print (when nesting positions for example). For more details, see remarks.
Remarks Origin and physical margins The origin (0,0) is located in the upper-left corner of the sheet. This origin takes the physical printer margins into account. Each printer includes physical margins in which no printing is possible. iMargin is used to define the "logical" print margins. If logical margins have been defined, iYPos manages the vertical position according to these new margins. Managing the <Immediate Calculation> parameter When <Vertical Position> is specified in iYPos, the function performs two actions at the same time: - Returns a control character string. This control character string modifies the print position when the string is printed.
- Immediately modifies the position of print cursor
The <Immediate Calculation> parameter is used to retrieve the control character string without modifying the current position of print cursor sMyTitle is string = "Print title" iDestination(iViewer) // --- CASE 1: <Immediate Calculation> is set to True (default) // Position the cursor at requested location // Note: The control character string is not retrieved here iXPos((iPageWidth() - iTextWidth(sMyTitle))/2) // Calculation to center the text // Print at cursor position (defined beforehand) iPrint(sMyTitle) // Must be centered // --- CASE 2: The same code with <Immediate Calculation> set to False // The control character string is not retrieved here // And the print cursor is not positioned because // <Immediate Calculation> is set to False // Note: Therefore, this line is not required iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, False) // Print at cursor position. // As the previous line of code did not change it, the text will be printed // at the previous position (at the beginning of line) iPrint(sMyTitle) // Therefore MUST NOT be centered // --- CASE 3: A single line of code // With <Immediate Calculation> set to True or to False, // the result is the same // The position of the print cursor is modified when // running iXPos, and when printing the // character string that contains the result returned by iXPos iPrint(iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, True) + sMyTitle) // Must be centered // The positioning is done twice: a little bit longer // but the result is the expected one // --- 3 B // The position of print cursor IS NOT modified when // running iXPos, BUT it is modified when // printing the character string that contains the result // returned by iXPos iPrint(iXPos((iPageWidth() - iTextWidth(sMyTitle))/2, False) + sMyTitle) // Must be centered // End of print iEndPrinting() When combining positions, unexpected results may occur. For example, the following code: iYPos(50) iPrint("First Part" + iYPos(30) + "Second Part") is not equivalent to: iPrint(iYPos(50) + "First Part" + iYPos(30) + "Second Part") In the first case, the entire character string is printed at vertical position 30. Indeed, in this case, iYPos(30) is run when building the string to print and therefore before the "First Part" string is printed. To get an identical result, all you have to do is use iYPos with the False parameter (in the first syntax): iYPos(30, False) will be actually run during the print. The same operation can be performed by iXPos. iYPos must not be used in a parameter of iPrintWord.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|