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:

NameDesccriptionXFRX
version
ReadDEVMODE
Read DEVMODE data for selected printer by PrinterName property. 17.0.0
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
17.0.0


The print parameter object has the following properties:


XFRX17.0.017.0017.0.019.1.0
NameType Desccriptionversion

AllOddEven

numberInclude all pages, odd or even only.  The allowed values are:
   1 ... all pages (default value)
   2 ... odd pages
   3 ... even pagesCopies
numberThe number of copies.
Zoomnumber

The number of pages per sheet.

lShowDialog 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 separated by commas (e.g. 3,4,5-9 or CURRENT (page)).
cDevmodestring DEVMODE structure. 
lPrintbooleanSpecifies whether a XFRX call PrintDocument() method.17.0.0
cOutputFilestring Output file name for XPS Microsoft Document Writer or another PDF virtual driver..
aFindStringarray 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. 
oWMobjectWatermark object.22.0
oEffectobjectEffect object22.0

UnderlinehyperlinksOnPrint

 
numberHyperlin decoration:
.NULL. - for backware compatiblity (default value)
0 - no decoration for hyperlinks
1 - display "normal" hyperlinks in blue, but do not decorate custom event hyperlinks (green)
2 - decorate both blue and green hyperlinks


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