4D v16.3

Print object

Home

 
4D v16.3
Print object

Print object 


 

Print object ( {* ;} object {; posX {; posY {; width {; height}}}} ) -> Function result 
Parameter Type   Description
Operator in If specified, object is an object name (string) If omitted, object is a variable
object  Form object in Object name (if * is specified) or Variable (if * is omitted)
posX  Longint in Horizontal location of object
posY  Longint in Vertical location of object
width  Longint in Width of object (pixels)
height  Longint in Height of object (pixels)
Function result  Boolean in True = object entirely printed; otherwise False

The Print object command lets you print the form object(s) designated by the object and * parameters, at the location set by the posX and posY parameters.

Before calling the Print object command, you must designate the table or project form containing the objects to be printed, using the FORM LOAD command. 

If you pass the optional * parameter, you indicate that the object parameter is an object name (character string). If you do not pass the * parameter, you indicate that object is a variable. In this case, you pass a variable reference (object type only) instead of a string.

The posX and posY parameters specify the starting point for printing the object(s). These values must be expressed in pixels. If these parameters are omitted, the object will be printed according to its location in the form. 

The width and height parameters are used to specify the width and height of the form object. The Print object command does not manage objects of variable size. You must use the OBJECT GET BEST SIZE command to manage the size of objects. You can also use the OBJECT GET BEST SIZE command to find out the most appropriate size for objects containing text. Similarly, Print object will not cause automatic page breaks. You must manage them according to your needs. 

You can use 4D commands to modify object properties (color, size, etc.) on the fly.

The command returns True if the object has been completely printed and False if this is not the case; in other words, if it was not able to print all the data associated with the object within the set framework. Typically, the command returns False when printing a list box if all the rows of the list box could not be printed. In this case, you can simply call the Print object command repeatedly until it returns True: a specific mechanism automatically causes the contents of the object to scroll after each call. 

Notes:

  • In the current version of 4D, only list box type objects have this mechanism (the command always returns True for any other type of object). In forthcoming versions of 4D, this functioning will be extended to other objects with variable contents.
  • The LISTBOX GET PRINT INFORMATION command lets you check the status of the printing during the operation.

The Print object command can only be used in the context of a print job opened beforehand with the OPEN PRINTING JOB command. If it is not called in this context, the command does nothing. Several Print object commands can be called in the same print job.

Note: Hierarchical lists, subforms and Web areas cannot be printed.

Example for printing ten objects in a form:

 PRINT SETTINGS
 If(OK=1)
    OPEN PRINTING JOB
    If(OK=1)
       FORM LOAD("PrintForm")
       x:=100
       y:=50
       GET PRINTABLE AREA(hpaper;wpaper)
       For($i;1;10)
          OBJECT GET BEST SIZE(*;"Obj"+String($i);bestwidth;bestheight)
          $end:=Print object(*;"Obj"+String($i))
          y:=y+bestheight+15
          If(y>hpaper)
             PAGE BREAK(>)
             y:=50
          End if
       End for
    End if
    CLOSE PRINTING JOB
 End if

Example of printing a complete list box:

 Repeat
    $end:=Print object(*;"mylistbox")
 Until($end)



See also 

FORM LOAD

 
PROPERTIES 

Product: 4D
Theme: Printing
Number: 1095

 
HISTORY 

Created: 4D v12

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)