By default, when users click the “Print” button in the previewer toolbar (), the Print method of the XFCont class is called. This method displays a dialog box with a printer selection and allows for entering a page range:
When a XFF file is previewed, the corresponding XFRX#DRAW reference is accessible via oXFRXWriter property of the previewer class instance.
If you would like to change the way the previewer reacts to the print event, you can either setup an extension handler (please see Registering an extension handler paragraph above in this chapter for more information) . There are three events that extension handler can implement:
Name | Description |
---|---|
This method is called when the Print button is clicked in the toolbar. | |
BeforePrintOptions | This method is called before the Printer Options dialog is opened. |
This method is called after the Printer Options dialog is closed, | |
BeforePrint | This method is called before the PrintDocument() method. |
AfterPrint | This method is called after the PrintDocument() method. |
The print parameter object has the following methods:
Name | Desccription | XFRX version |
---|---|---|
ReadDEVMODE | Read DEVMODE data for selected printer by PrinterName property. | 17.0.0 |
SetField | Set field of DEVMODE data for selected printer by PrinterName property. Parameters: tcField – Field name, such as "DM_COLOR", "DM_PRINTQUALITY" etc. tuValue – Fields' value | 17.0.0 |
The print parameter object has the following properties:
Name | Type | Desccription | XFRX version |
---|---|---|---|
AllOddEven | number | Include all pages, odd or even only. The allowed values are: 1 ... all pages (default value) | |
Copies | number | The number of copies. | |
Zoom | number | The number of pages per sheet. | |
lShowDialog | boolean | Specifies whether a XFRX call "Print options" dialog. | 17.0.0 |
PrinterName | string | The name of the printer to which the document will be sent. | |
PageRange | string | Enter page numbers and/or page ranges separated by commas (e.g. 3,4,5-9 or CURRENT (page)). | |
cDevmode | string | DEVMODE structure. | |
lPrint | boolean | Specifies whether a XFRX call PrintDocument() method. | 17.0.0 |
cOutputFile | string | Output file name for XPS Microsoft Document Writer or another PDF virtual driver. | 17.0.0 |
aFindString | array | A array contains strings for highlight. The array can has one column - than background color will be yelow for all strings. Or cab has two columns - than second column contains background color for string. | 17.0.0 |
oWM | object | Watermark object. | 22.0 |
oEffect | object | Effect object | 22.0 |
UnderlinehyperlinksOnPrint | number | Hyperlin decoration: .NULL. - for backware compatiblity (default value) | 19.1.0 |
The printer job name generated by the Print method is stored in cJobName property of the XFCont class and can be changed both in design time and runtime. (The default value is “XFRX”).
See also: Printing XFF files chapter on page 46 for more information about printing the content of XFF files.
Extension handler examples
USE invoices ORDER customer LOCAL m.loSession, m.lnRetval, m.loXFF, m.loPreview, m.loScripts m.loSession=EVALUATE([xfrx("XFRX#LISTENER")]) m.lnRetVal = m.loSession.SetParams("",,,,,,"XFF") && no name = just in memory IF m.lnRetVal = 0 REPORT FORM invoices OBJECT m.loSession m.loXFF = m.loSession.oxfDocument * * initialize the previewer * SET CLASSLIB TO xfrxlib ADDITIVE m.loPreview = CREATEOBJECT("frmMPPreviewer") m.loPreview.setExtensionHandler(CREATEOBJECT("MyExtensionHandler")) m.loPreview.windowType = 0 m.loPreview.iBook = 0 m.loPreview.PreviewXFF(loXFF) m.loPreview.show(1) ENDIF DEFINE CLASS MyExtensionHandler AS Custom PROCEDURE BeforePrintOptions LPARAMETERS m.toXFF, m.loOpt m.loOpt.Copies=2 && new default value RETURN .T. *RETURN .F. && XFRX cancel printing document - "Print options" dialog was not call ENDPROC PROCEDURE PrintOptions LPARAMETERS m.toXFF, m.loOpt DEBUGOUT m.loOpt.PrinterName && log printer name m.loOpt.Copies=MAX(m.loOpt.Copies, 5) && cutomer can print only five copies RETURN .T. *RETURN .F. && XFRX cancel printing document ENDPROC ENDDEFINE