PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Origin and physical margins
  • Managing the parameter
  • Combining positions
  • Printing in Java and Android
  • Various
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
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.
Note: 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.
Versions 18 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 18
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 19 and later
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
New in version 19
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
Android This function is now available for the Android applications.
Android Widget This function is now available in Android Widget mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
// 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). See remarks for more details.
Remarks

Origin and physical margins

The origin (0,0) is located in the top 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"
iPreview()
// --- 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 code line 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 code line
// 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()

Combining positions

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.
AndroidAndroid Widget Java

Printing in Java and Android

The prints can be less precise because the print resolution is set to 72 dot per inch (dpi) even if the printer supports higher resolutions.
Consequence: The calculations of points in images and in drawings (lines for example) are rounded during the position calculations when printing, especially for small values. During the print, the calculations are performed in point (according to the print resolution) instead of mm (or cm).
Example: Printing lines in Java: if the spacing between the lines is set to 0.5 mm, how many points will be found between each line (resolution set to 72 ppp)?
The first line is positioned at 0.5 mm which means (0.5/25.4) inches with a resolution of 72 points per inch (ppp): (0.5/25.4) x 72 = 1.42 point. The point being the base unit, it cannot be divided: the result is automatically rounded to 1 point less or greater according to the case.
This is a succession of lines printed with a spacing set to 05 mm:
  • 0.5 mm --> (1.42) 1 point
  • 1.0 mm --> (2.84) 3 points
  • 1.5 mm --> (4.25) 4 points. Caution: the line found at 1.5 mm is stuck to the line found at 1 mm (no spacing between these two lines)
  • 2.0 mm --> (5.67) 6 points
  • 2.5 mm --> (7.09) 7 points. Caution: the line found at 2.5 mm is stuck to the line found at 2 mm (no spacing between these two lines)
  • 3.0 mm --> (8.50) 9 points
  • 3.5 mm --> (9.92) 10 points. Caution: the line found at 3.5 mm is stuck to the line found at 3 mm (no spacing between these two lines)
  • 4.0 mm --> (11.33) 11 points. Caution: the line found at 4 mm is stuck to the line found at 3.5 mm (no spacing between these two lines)
  • etc.
To get a proper representation (no rounding), the size and/or the position in mm for a resolution set to 72 ppp must be a multiple of 127/360.
1 point --> (1/72) pouces --> (1/72) x 25.4 mm = 127/360 = 0.3527778 mm

Various

iYPos must not be used in a parameter of iPrintWord.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230prn.dll
Windows Mobile wp230prn.dll
Java wd230java.jar
Linux wd230prn.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment