AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de impresión
  • Origin and physical margins
  • Managing the parameter
  • Combining positions
  • Printing in Java and Android
  • Miscellaneous
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Controls the vertical position (ordinate or line) of the print cursor on the page. You can:
  • find out the current vertical position,
  • modify the vertical position of print cursor.
Note When printing a text string, the current vertical position points to the top of the string to be printed. The bottom print line depends on the height of the fonts used in the printed line.
Ejemplo
// 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()
Sintaxis

Finding out the vertical position of print cursor Ocultar los detalles

<Result> = iYPos()
<Result>: Real
Current vertical position of cursor (in millimeters).

Modifying the vertical position of print cursor Ocultar los detalles

<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.
Observaciones

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: <Calcul immédiat> to True (default)
// Position the cursor at requested location
// Note: The control 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 the <Calcul immédiat> parameter 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: So this line is useless
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: Single-line 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
// Positioning is done twice: a little heavier
// 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. In this case, the function iYPos(30) function is executed when the string to be printed is constructed, and therefore before the "First part" string is printed.
To obtain the same result, simply use (in the first syntax) the function iYPos with the parameter False parameter: the iPosY(30, False) function will only really be executed during printing.
The same operation can be performed by iXPos.
AndroidWidget Android

Printing in Java and Android

Printouts can be less precise because the print resolution is set to 72 dpi even if the printer supports higher resolutions.
As a consequence, the position of points of images and drawings (lines for instance) is rounded, especially when working with small values. During the print job, calculations are performed in points (depending on the print resolution) instead of mm (or cm).
Example: Printing in Java: if the lines are 0.5 mm apart, how many points are there between each line in Java (resolution 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 depending on 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 at 1.5 mm is combined with the line at 1 mm (there is no space between these two lines)
  • 2.0 mm --> (5.67) 6 points
  • 2.5 mm --> (7.09) 7 points. Caution: the line at 2.5 mm is combined with the line at 2 mm (there is no space between these two lines)
  • 3.0 mm --> (8.50) 9 points
  • 3.5 mm --> (9.92) 10 points. Caution: the line at 3.5 mm is combined with the line at 3 mm (there is no space between these two lines)
  • 4.0 mm --> (11.33) 11 points. Caution: the line at 4 mm is combined with the line at 3.5 mm (there is no space between these two lines)
  • etc.
To get an accurate representation (without 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) inches --> (1/72) x 25.4 mm = 127/360 = 0.3527778 mm

Miscellaneous

iYPos must not be used in a parameter of iPrintWord.
Componente: wd300prn.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local