4D v16.3

SET CURRENT PRINTER

Home

 
4D v16.3
SET CURRENT PRINTER

SET CURRENT PRINTER 


 

SET CURRENT PRINTER ( printerName ) 
Parameter Type   Description
printerName  String in Name of printer to be used

The SET CURRENT PRINTER command is designates the printer to be used for printing with the current 4D application.

Pass the name of the printer to be selected in the printerName parameter. To get a list of available printers, use the PRINTERS LIST command beforehand.
If you pass an empty string in printerName, the current printer defined in the system will be used.

SET CURRENT PRINTER allows you to designate the generic PDF printer of the system in order to print PDFs. The value to use depends on the version of the OS as well as that of 4D.

  • Windows 8 and previous versions:
    4D relies on the PDFCreator driver to facilitate the printing of PDF documents under Windows (see the Integration of PDFCreator driver under Windows section). To print a PDF document, in the printerName parameter, pass the name of the virtual printer that was installed by the PDFCreator driver. By default, the name of the virtual printer is "PDFCreator". However, this name may have been modified when the driver was installed. In order for 4D to automatically look for and use the name of the virtual printer, even if it has been customized, in the printerName parameter you must pass the following constant (Print Options theme):
    Constant Type Value
    PDFCreator Printer name String PDFCreator
  • Starting with Windows 10:
    Windows 10 includes a native PDF printer driver, which allows 4D to create PDFs directly without it being necessary to use a third-party driver such as PDFCreator.
    The name of the driver is "Microsoft Print to PDF" (see the example found in the Integration of PDFCreator driver under Windows section).
  • Under OS X and starting with Windows 10 (4D v15 R5 64-bit and higher):
    A constant found in the Print Options theme allows you to designate the generic PDF printer automatically, regardless of the platform. This facilitates the writing of generic code.
    Constant Type Value Comment
    Generic PDF driver String _4d_pdf_printer Note: This function is not available in 32-bit versions of 4D.
    • On OS X, sets the current printer to the default driver. This driver is invisible; it is not found in the list returned by PRINTERS LIST. Note that a PDF document path must have been set using SET PRINT OPTION,  otherwise error 3107 is returned.
    • On Windows, sets the current printer to the Windows PDF driver (named "Microsoft Print to PDF"). This constant is only available in Windows 10 with the PDF option installed. In other Windows versions, or if no PDF driver is available, the command does nothing and the OK variable is set to 0.

The SET CURRENT PRINTER command must be called before SET PRINT OPTION, so that the options available correspond to the selected printer. On the other hand, SET CURRENT PRINTER must be called after PAGE SETUP, otherwise the print settings are lost.

This command can be used with the PRINT SELECTION, PRINT RECORD, Print form, and QR REPORT commands, and is applied to all 4D printing, including that in Design mode.
It is imperative for print commands to be called with the > parameter (where applicable) so that the specified settings are not lost.

If printer selection is carried out correctly, the system variable OK is set to 1. Should the opposite occur (for instance if the designated printer is not found), the system variable OK is set to 0 and the current printer remains unchanged.

Example  

Creation of a PDF document under Windows 10 with 4D Developer Edition 64-bit:

 C_TEXT($pdfpath)
 $pdfpath:=System folder(Desktop)+"test.pdf"
 SET CURRENT PRINTER(Generic PDF driver)
 SET PRINT OPTION(Destination option;2;$pdfpath)
 ALL RECORDS([Table_1])
 PRINT SELECTION([Table_1];*)
 SET CURRENT PRINTER("")



See also 

Get current printer
PRINTERS LIST

 
PROPERTIES 

Product: 4D
Theme: Printing
Number: 787

The OK variable is changed by the command

 
HISTORY 

Created: 4D 2003
Modified: 4D v12
Modified: 4D v15 R5

 
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)