4D v14.3

SET PRINT OPTION

Home

 
4D v14.3
SET PRINT OPTION

SET PRINT OPTION 


 

SET PRINT OPTION ( option ; value1 {; value2} ) 
Parameter Type   Description
option  Longint, String in Option number or PDF option code
value1  Longint, String in Value 1 of the option
value2  Longint, String in Value 2 of the option

The SET PRINT OPTION command is used to modify, by programming, the value of a print option. Each option defined using this command is applied to the entire database and for the duration of the session as long as no other command that modifies print parameters (PRINT SETTINGS, PRINT SELECTION without the > parameter, etc.) is called.

The option parameter allows you to indicate the option to be modified. You can pass either one of the predefined constants of the “Print Options” theme, or a PDF option code (usable with the PDFCreator driver under Windows only).

Pass the new value(s) of the specified option in the value1 and (optionally) value2 parameters. The number and nature of the values to be passed depend on the type of option specified.

The following table lists the options and their possible values:

option (constant)value1value2
1 (Paper option)Name-
WidthHeight
2 (Orientation option)1=Portrait, 2=Landscape-
3 (Scale option)Number (%)-
4 (Number of copies option)Number-
5 (Paper source option)Windows only:
Index (number)-
8 (Color option)Windows only:
1=N/B, 2=Color-
9 (Destination option)1=Printer,-
2=(PC)/PS File (Mac), Access path
3=PDF File,Access path
5=Screen (Mac)-
11 (Double sided option)Windows only:
0=Single-sided (standard)-
1=Double-sidedBinding: 0=Left (default), 1=Top
12 (Spooler document name option)Name of document-
to be printed
13 (Mac spool file format option)0=PDF mode, 1= PostScript-
mode
14 (Hide printing progress option)0=Display (default),-
1=Hide
  • Paper option (1): the list of all the names of available paper can be obtained using the PRINT OPTION VALUES command.
    You can either pass the name of the paper in value1 (and, in this case, omit value2), or pass the paper width in value1 and its height in value2. The width and height must be expressed in screen pixels.
  • Orientation option (2): you can pass either 1 (Portrait), or 2 (Landscape) in value1.
  • Scale option (3): pass a percentage in value1. Be careful, some printers do not allow you to modify the scale. If you pass an invalid value, the property is reset to 100% at the time of printing.
  • Number of copies option (4): pass the number of copies to be printed in value1.
  • Paper source option (5): pass the number corresponding to the index, in the array of trays returned by the PRINT OPTION VALUES command, of the paper tray to be used.
    Note:
    This option can only be used under Windows.
  • Color option (8): in value1, pass the code specifying the mode for handling color: 1=Black and white (monochrome), 2=Color.
    Note:
    This option can only be used under Windows.
  • Destination option (9): in value1, pass the code specifying the type of print destination: 1=Printer, 2=(PC)/PS File (Mac), 3=PDF file, 5=Screen (Mac OS X driver option).
    If value1 is different from 1 or 5, pass the pathname for the resulting document in value2. This path will be used until another path is specified. If a file with the same name already exists at the destination location, it will be replaced.
    Note
    : Under Windows, you can set the printing destination to 3 (PDF File) when the PDF Creater driver has been installed. Beginning with 4D version 12.2, this setting is mandatory in order for 4D to control printing through PDF Creater under Windows. When the (9;3;path) values are passed, 4D automatically starts a "silent" PDF printing which takes into account any option codes that are passed (note that if you pass an empty string in value2 or omit this parameter, a file saving dialog appears at the time of printing. After printing, the current settings are restored. This simplifies control of printing PDFs for 4D and lets you write multi-platform code.
    When the (9;3;path) values are not passed, printing is not controlled by 4D and any PDF Creater option codes that were passed are ignored.
  • Double sided option (11): you can either pass 0 (Single-sided or standard), or 1 (Double-sided) in value1. If value1 equals 1, you can define the binding to be applied using value2: 0=Left binding (default value), 1=Top binding.
    Note:
    This option can only be used under Windows.
  • Spooler document name option (12): in value1, pass the name of the print document that must appear in the list of spooler documents.
    To use or restore standard operation (using the method name in the case of a method, the table name for a record, etc.), pass an empty string in value1.
    Warning:
    The name defined by this statement will be used for all the print documents of the session for as long as a new name or an empty string is not passed.
  • Mac spool file format option (13): in value1, pass 0 to set the print job in PDF mode (default value) and 1 to “force” the print job in PostScript mode. This option has no effect under Windows.
    Note:
    Under Mac OS X, printing is done as a PDF by default. However, the PDF print driver does not support PICT pictures with encapsulated PostScript information — these pictures are generated, more particularly, by vectorial drawing software.
    To avoid this problem, this option lets you modify the print mode to use under Mac OS X for the current session. Keep in mind that printing in PostScript mode can lead to undesired side effects.
  • Hide printing progress option (14): pass 1 in value1 to hide the progress windows and 0 to display them again (default operation). This option is particularly useful in the case of PDF printing under Mac OS X.
    Note:
    There is already a Printing progress option found in the Database Settings dialog box (Interface page). However, it is applied globally to the application and does not hide all the windows under Mac OS X.

Once set using this command, a print option is kept throughout the duration of the session for the entire 4D application. It will be used by the PRINT SELECTION, PRINT RECORD, Print form and QR REPORT commands, as well as for all 4D printing, including that in Design mode.

Notes:

  • It is indispensable to use the optional > parameter with the PRINT SELECTION, PRINT RECORD and PAGE BREAK commands in order to avoid resetting the print options that were set using the SET PRINT OPTION command.
  • The SET PRINT OPTION command only operates with PostScript printers.

In order to be able to use a PDF option code in the option parameter, you must have installed the PDFCreator driver in your 4D environment (for more information, refer to the Integration of PDFCreator driver under Windows section). Moreover, in order for option codes to be taken into account, you need to have enabled control of PDF printing for 4D using the following statement:

 SET PRINT OPTION(Destination option;3;fileName)

Otherwise, option codes are ignored.

A PDFoption code is a Text type value consisting of two parts, OptionType and OptionName, combined together as "OptionType:OptionName". Here is the description of this code:

  • OptionType Indicates whether you are specifying a native PDFCreator option or a 4D PDF administration option. Two values are accepted:
    • PDFOptions = native option
    • PDFInfo = internal option.
  • OptionName Specifies the option to be set (depending on the OptionType value).
    • If OptionType = PDFOptions, you can pass one of several PDFCreator native options in OptionName. For example, the UseAutosave option affects the automatic backup. In order to be able to modify this option, pass "PDFOptions:UseAutosave" in the option parameter and the value to be used in the value1 parameter. For a complete description of the PDFCreator native options, please refer to the documentation provided with the PDFCreator driver.
    • If OptionType = PDFInfo, you can pass one of the following specific selectors in OptionName:
      • Reset print: used to reset the internal waiting status in order, more particularly, to exit from an infinite loop. In this case, value1 is not used.
      • Reset standard options: used to reset all the PDFCreator options to their default values. If printing is in progress, the default settings are applied after its completion. In this case, value1 is not used.
      • Start: used to start or stop the PDFCreator spooler. Pass 0 in value1 to stop it and 1 to start it.
      • Reset options: used to reset all the options modified since the beginning of the session using the SET PRINT OPTION command and the PDFOptions selector.
      • Version: used to read the current version number of the PDFCreator driver. This selector can only be used with the GET PRINT OPTION command. The number is returned in the value1 parameter.
      • Last error: used to read the last error returned by the PDFCreator driver. This selector can only be used with the GET PRINT OPTION command. The error number is returned in the value1 parameter.
      • Print in progress: used to find out if 4D is waiting for printing by PDFCreator. This selector can only be used with the GET PRINT OPTION command. The value1 parameter returns 1 if 4D is waiting for PDFCreator and 0 otherwise. 
      • Job count: used to find out the number of jobs waiting in the printing queue. This selector can only be used with the GET PRINT OPTION command. The number of jobs is returned in the value1 parameter.
      • Synchronous Mode: used to set the synchronization mode betwen printing requests sent by 4D and the PDFCreator driver. Since 4D cannot get information about the current status of a print job that is in the printing queue, this option can be used to better control the execution of the jobs by only sending them when the status of the PDFCreator driver is "free". In this case, 4D is synchronized with the driver. Pass 0 in value1 for 4D to send print requests immediately (default value) and 1 in order for 4D to be synchronized and to wait for the driver to have finished the job in progress before sending another one. 

Note: After each printing, 4D automatically re-establishes the previous settings of the PDFCreator driver in order to avoid any interference with other programs using PDFCreator.

Example  

The following method enables the PDF driver so as to print all the records of the table at the C:\Test\Test_PDF_X location where X is the sequence number of the record: 

 SET CURRENT PRINTER(PDFCreator Printer Name)
  // Under Windows, select the virtual printer installed by PDFCreator
 If(OK=1) // If PDFCreator is actually installed
 
    ALL RECORDS([Table_1])
    For($i;1;Records in selection([Table_1]))
       SET PRINT OPTION(Destination option;3;"C:\\Test\\Test_PDF_"+String($i))
  // Destination option 3 launches a PDFCreator print job
       PRINT RECORD([Table_1];*)
       NEXT RECORD([Table_1])
    End for
  // Resetting of the PDFCreator driver options
    SET PRINT OPTION("PDFInfo:Reset standard options";0)
 End if

The system variable OK is set to 1 if the command has been executed correctly; otherwise, it is set to 0.

If you pass an invalid option code (option not recognized by PDFCreator for example), OK is set to 0.

If the value passed for an option is invalid or if it is not available on the printer, the command returns an error (that you can intercept using an error-handling method installed by the ON ERR CALL command) and the current value of the option remains unchanged.

 
PROPERTIES 

Product: 4D
Theme: Printing
Number: 733

The OK variable is changed by the commandThis command modifies the Error system variableMac OS specificWindows specific

 
HISTORY 

Modified: 4D 2004.3
Modified: 4D v12
Modified: 4D v12.2

 
SEE ALSO 

GET PRINT OPTION
PRINT OPTION VALUES
SET CURRENT PRINTER

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)

Inherited from : SET PRINT OPTION ( 4D v11 SQL Release 6)