Skip to main content
Version: Next

BLOB to print settings

BLOB to print settings ( printSettings {; params} ) : Integer

ParameterTypeDescription
printSettingsBlobBLOB containing print settings
paramsInteger0=Restore saved values for number of copies and page range, 1=Reset to default values
Function resultIntegerStatus code: 1=Operation successful, 0=No current printer, -1=Incorrect parameters, 2=Printer changed

This command is not thread-safe, it cannot be used in preemptive code.

Description

The BLOB to print settings command replaces the current 4D print settings with the parameters stored in the printSettings BLOB. This BLOB must have been generated by the Print settings to BLOB command or the 4D Pack command (see below).

The params parameter allows you to define how to handle the basic "number of copies" and "page range" settings:

  • If you pass 0 or omit this parameter, the values stored in the BLOB are restored,
  • If you pass 1, the values are reset to default: the number of copies is set to 1 and the page range is set to "all pages".

The parameters are applied to the current 4D printing settings as long as no command such as _o_PAGE SETUP, SET PRINT OPTION or PRINT SELECTION without the > parameter modifies them. The parameters set are used more particularly by the PRINT SELECTION, PRINT LABEL, PRINT RECORD, Print form and QR REPORT commands, as well as by the menu commands of 4D, including those of the Design environment.

The PRINT SELECTION, PRINT LABEL, and PRINT RECORD commands must be called with the > parameter (if applicable) in order for the settings defined by BLOB to print settings to be kept.

The command returns one of the following status codes:

  • -1: the BLOB is incorrect,
  • 0: no current printer is selected (in this case the command does nothing),
  • 1: the BLOB has been correctly loaded,
  • 2: the BLOB has been correctly loaded but the current printer name has changed(*).
    Note: Code (2) is always returned if the BLOB was created by the 4D Pack command, even if the printer name did not actually change, since this information was not included in the 4D Pack BLOBs.

(*) Settings depend on the currently selected printer at the moment the BLOB was saved. Applying these settings to a another printer is supported if both printers are of the same model. If the printers are different, only common parameters will be restored.

Windows / OS X

The printSettings BLOB can be saved and read on both platforms. However, even if some print settings are common, some others are platform-specific and depend on the drivers and system versions. If the same printSettings BLOB is shared between both platforms, you may lose parts of the information.
When used in a heterogeneous environment, in order to restore the maximum settings available for each platform (and not only the common part), it is recommended that you work with two printSettings BLOBs, one for each platform.

Compatibility with 4D Pack commands

The print settings BLOBs generated by the legacy command from 4D Pack can be loaded and used by the BLOB to print settings command. Note however that if they are saved using Print settings to BLOB, they are converted and can no longer be opened using . The BLOB to print settings command stores much more printing information than .

Example

You want to apply print settings previously saved to disk to the current 4D printing context:

 var curSettings : Blob
 DOCUMENT TO BLOB(Get 4D folder(Active 4D Folder)+"current4Dsettings.blob";curSettings)
  //current4Dsettings has been created by Print settings to BLOB
 $err:=BLOB to print settings(curSettings;0)
 Case of
    :($err=1)
  //everything is OK
    :($err=2)
       CONFIRM("Printer has changed!\n\nCheck the print settings?")
       If(OK=1)
          PRINT SETTINGS
       End if
    :($err=0)
       ALERT("There is no current printer.")
    :($err=-1)
       ALERT("Invalid settings file.")
 End case

See also

Print settings to BLOB