Skip to main content
Version: 20 R7 BETA

Print object

Print object ( {* ;} object {; posX {; posY {; width {; height}}}} ) : Boolean

ParameterTypeDescription
*OperatorIf specified, object is an object name (string)
If omitted, object is a variable
objectanyObject name (if * is specified) or
Variable (if * is omitted)
posXIntegerHorizontal location of object
posYIntegerVertical location of object
widthIntegerWidth of object (pixels)
heightIntegerHeight of object (pixels)
Function resultBooleanTrue = object entirely printed; otherwise False

Description

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. If the user cancels the printing operation, a -128 error is generated, that you can intercept using ON ERR 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).
  • 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 1

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 2

Example of printing a complete list box:

 OPEN PRINTING JOB
 FORM LOAD("myForm")
 $Over:=False
 gError:=0
 ON ERR CALL("err")
 Repeat
    $Total:=Print object(*;"List_Box")
    LISTBOX GET PRINT INFORMATION(*;"List_Box";lk printing is over;$Over)
    PAGE BREAK
    If(gError=-128) //the user has cancelled the operation
       $Over:=True
    End if
 Until($Over)
 CLOSE PRINTING JOB
 ON ERR CALL("")

See also

FORM LOAD

Properties

Command number1095
Thread safe