Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:


NameDescription

Print

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.

PrintOptions

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:

17.0.017.0.0
NameDesccriptionXFRX
version
ReadDEVMODE
Read DEVMODE data for selected printer by PrinterName property. 
SetFieldSet field of DEVMODE data  for selected printer by PrinterName property. 
Parameters:
   tcField – Field name, such as "DM_COLOR", "DM_PRINTQUALITY" etc.
   tuValue – Fields' value


The print parameter object has the following properties:


NameType Desccription

AllOddEven

numberInclude all pages, odd or even only.
CopiesnumberThe number of copies.
Zoomnumber

The number of pages per sheet.

lShowDialog boolean Specifies whether a XFRX call "Print options" dialog. 
PrinterNamestring The name of the printer to which the document will be sent.
PageRangestringEnter page numbers and/or page ranges.
cDevmodestring DEVMODE structure. 
lPrintbooleanSpecifies whether a XFRX call PrintDocument() method.
cOutputFilestring Output file name for XPS Microsoft Document Writer or another PDF virtual driver.
aFindStringarray A array contains strings for  highlight. 
oWMobjectWatermark object.
oEffectobjectEffect object

UnderlinehyperlinksOnPrint

numberHyperlin decoration.


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

Code Block
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