Printing from the previewer
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 |
---|---|
ReadDEVMODE | Read DEVMODE data for selected printer by PrinterName property. |
SetField | Set field of DEVMODE data for selected printer by PrinterName property. |
The print parameter object has the following properties:
Name | Type | Desccription |
---|---|---|
number | Include all pages, odd or even only. | |
Copies | number | The number of copies. |
Zoom | number | The number of pages per sheet. |
lShowDialog | boolean | Specifies whether a XFRX call "Print options" dialog. |
PrinterName | string | The name of the printer to which the document will be sent. |
PageRange | string | Enter page numbers and/or page ranges. |
cDevmode | string | DEVMODE structure. |
lPrint | boolean | Specifies whether a XFRX call PrintDocument() method. |
cOutputFile | string | Output file name for XPS Microsoft Document Writer or another PDF virtual driver. |
aFindString | array | A array contains strings for highlight. |
oWM | object | Watermark object. |
oEffect | object | Effect object |
number | Hyperlin decoration. |
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