This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
SET PRINT OPTION
|
SET PRINT OPTION ( option ; value1 {; value2} ) | ||||||||
Parameter | Type | Description | ||||||
option | Longint |
![]() |
Option number or PDF option code | |||||
value1 | Longint, Text |
![]() |
Value 1 of the option | |||||
value2 | Longint, Text |
![]() |
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. If a print job has been opened (e.g. with OPEN PRINTING JOB), the option is set for the job and cannot be modified as long as the job has not terminated (except for the Orientation option, see below) .
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:
Constant | Type | Value | Comment |
Paper option | Longint | 1 | If you use only value1, it contains the name of the paper. If you use both parameters, value1 contains the paper width and value2 contains the paper height. The width and height are expressed in screen pixels. Use the PRINT OPTION VALUES command to get the name, height and width of all the paper formats offered by the printer. |
Orientation option | Longint | 2 | value1 only: 1=Portrait, 2=Landscape. If a different orientation option is used, GET PRINT OPTION returns 0 in value1. This option can be called within a print job, which means that you can switch from portrait to landscape, or vice versa, during the same print job. |
Scale option | Longint | 3 | value1 only: scale value in percentage. 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 | Longint | 4 | value1 only: number of copies to be printed. |
Paper source option | Longint | 5 | (Windows only) value1 only: number corresponding to the index, in the array of trays returned by the PRINT OPTION VALUES command, of the paper tray to be used. This option can only be used under Windows. |
Destination option | Longint | 9 | value1: code specifying the type of print destination: 1=Printer, 2=File (PS on Mac), 3=PDF file, 5=Screen (OS X driver option). |
Double sided option | Longint | 11 | value1: 0=Single-sided or standard, 1=Double-sided. If value1=1, value2 contains the binding: 0=Left binding (default value), 1=Top binding. |
Spooler document name option | Longint | 12 | value1 only: name of the current print document, which appears in the list of spooler documents. 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. 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. |
Page range option | Longint | 15 | value1=first page to print (default value is 1) and (optional) value2=number of the last page to print (default value -1 = end of document). |
Legacy printing layer option | Longint | 16 | (Windows only) value1 only: 1=select the GDI-based legacy printing layer for the subsequent printing jobs. 0=select the D2D printing layer (default). This selector is mainly intended to allow legacy plug-ins to print inside 4D jobs in 4D applications on Windows. |
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, QR REPORT and WP PRINT commands, as well as for all 4D printing, including that in Design mode.
Notes:
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)
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:
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.
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 value of Orientation option can be modified within the same print job. Note that the option must have been set before the PAGE BREAK command:
ALL RECORDS([People])
PRINT SETTINGS
If(OK=1)
OPEN PRINTING JOB
SET PRINT OPTION(Orientation option;1) //portrait
Print form([People];"Vertical_Form")
SET PRINT OPTION(Orientation option;2) //landscape
PAGE BREAK //must be called imperatively AFTER the option
Print form([People];"Horiz_Form")
CLOSE PRINTING JOB
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.
GET PRINT OPTION
PRINT OPTION VALUES
Print Options
SET CURRENT PRINTER
Product: 4D
Theme: Printing
Number:
733
Modified: 4D 2004.3
Modified: 4D v12
Modified: 4D v12.2
Modified: 4D v15 R5
Modified: 4D v16
4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)