Using the dBL Print Control package
by Rick Miller     -     August, 2004

T he dBLprint object is a control for setting and managing dBASE printer objects.

This is accomplished by the user modifying a profile.
A profile has no affect on the windows printing system for other printing needs.

dBLprint uses a profile to assign properties to a dBASE printer object.

The dBL Print Control package comes with 2 different ways to use dBLprint.
 
      1) Indirectly with the dBLprintButton object.
            a) properties.
            b) methods.

      2) Directly with the dBLprint object.
            a) properties.
            b) methods.

      Questions on direct use.
            a) How is a dBLprint object created ?
            b) How is a profile created ?
            c) How is it used with a dBASE Report object ?
            d) Where is the beef (real world) ?
 



W orking with the dBLprintButton control.
The easiest way to start using the dBLprint object is with the dBLprintButton (pushbutton) object.
After installation of the dBL Print Control package, start dBASE and change directories to the installation folder.
Run the file dBLPrintDemo.wfm.
Click the "Add to Component Palette" button.
A dBLprintButton object will now be available in the form designer.


Methods of dBLprintButton.
dBLprintButton Method
  choosePrinter open a dialog for changing a profile.
  print print a report using a profile.
  preview display a report in a form.

Properties of dBLprintButton.
dBLprintButton Property Default
  appname "dBLPrint" specifies the profile to work with.
  margins false used to determine whether to show the Margin adjustment area with choosePrinter.
  options true used to determine whether to show the Options button with choosePrinter.
  printer "" further specifies the profile to work with.
  reportClass "" report className to use with preview or print method.
  reportFile "" file name holding the reportClass property value.
  streams false used to determine whether to show the Margin adjustment area with choosePrinter.
  testClass "" report className used by the Test button with choosePrinter.
  testFile "" file name holding the testClass property value.
  viewerClass "" form className to use with the preview method.
  viewerFile "" file name holding the viewerClass property value.


The profile that is used by an instance of dBLprintButton is determined by the 2 properties appname and printer.
These properties would normally be assigned within the application.
A good place to assign these properties are in an onOpen event of either the dBLprintButton object or the form that contains it. They may be assigned by any other means of imagination as well.

The choosePrinter method opens a printer dialog.
The dialog values are saved to a profile when the user selects the OK button in the dialog.
The dialog makes use of 7 properties.
appname, printer, margins, streams, options, testClass, testFile.


The print method prints a report using a profile.
It makes use of 6 properties.
appname, printer, margins, streams, reportClass, reportFile.
 
A dBLprint object is created using the profile (from the appname and printer properties).
An instance of the report (from the reportClass property) is created using the file (from the reportFile property).
The profile is applied to the report printer object.
The report is output to printer.
The report is destroyed.
The dBLprint object is destroyed.
User control is returned to the form.
 

Back to the Top

W orking directly with the dBLprint object.
How is a dBLprint object created ?
 
oRef = new dBLprint( [<char> application name, [<char> printer name]])
example:     oRef = new dBLprint("Payroll", "Reports")
 

Methods of dBLprint.
dBLprint Method
  enumPaperSize(<char> printer name) returns a 2 column array of printer paper sizes.
  enumPaperSource(<char> printer name) returns a 2 column array of printer paper trays.
  enumPorts(<array> printer names) returns a 1 column array of printer ports matching a printer array.
  enumPrinters() returns a 1 column array of printer names.
  get(<char> property name) returns a property value.
  getPdriver(<char> printer name) returns a driver name for use with _pdriver.
  getPort(<char> printer name) returns a port name.
  getDefaultPrinter() returns the windows default printer name.
  release() release object from memory.
  set(<char> property, <pVal> value) set a property value, returns true/false (success/fail).
  setDefaultLanguage(<char> language) set language for dialogs, returns true/false (success/fail).
  setDefaultPrinter(<char> printer name) set the windows default printer, returns true/false (success/fail).
  setPrinter(<pRef> printer object) assigns properties to a printer object, returns true/false (success/fail).
  showPrinter([<int> hwnd]) returns true/false (OK/Cancel).

Let's go ahead and create a profile .
Then we will apply the profile to _app.printer.
 
set procedure to dBLprint.co additive
// Note: we are using dBLprint.co instead of dBLprint.cc
// for compatibility with all 32 bit versions of dBASE.

oRef = new dBLprint("TestApp", "Checks")
oRef.showPrinter()

// make a couple of selections and then click the OK button.

 
inspect(_app.printer)
// notice a few of the property values.

 
oRef.setPrinter(_app.printer)
// notice a few of the properties have changed.
// You may need to toggle the tabs to refresh the inspector.
// close the inspector.

 
inspect(oRef)
// the properties and methods of oRef (dBLprint) are displayed.

 
oRef.release()
 

Properties of dBLprint.
dBLprint Property Default
  colorNormal "BtnFace" colorNormal property of the showPrinter dialog.
  margins false do margin values get added to pageTemplate1 with setPrinter ?
  options true does the Options button appear with showPrinter ?
  reportClass "" report className used by showPrinter Test button.
  reportFile "" file name holding the reportClass property value.
  streams false do margin values get added to streamFrame1 with setPrinter ?
  text " Printer Selection" caption used in the showPrinter dialog.

Back to the Top

How does dBLprint work with a dBASE report object ?
The setPrinter method is used to interact with 3 report objects.
      1) printer (normally used to output the report to paper).
      2) pageTemplate1 (normally used to display Titles, dates, and page numbers).
      3) streamFrame1 (normally used to display information from data files).

A dBASE printer object has several properties affecting output.
 
color <int> 0=Default, 1=Mono, 2=Color/Shades of gray.
copies <int> 1 Number of prints to make.
duplex <int> 0=Default, 1=None, 2=Duplex vertical, 3=Duplex horizontal.
orientation <int> 0=Default, 1=Portrait, 2=Landscape.
paperSize <int> Evaluates to a Width x Height paper size.
paperSource <int> Evaluates to a paper tray or bin.
printerName <char> Name displayed in the windows printer applet.
printerSource <int> 0=Windows default, 1=dBASE default, 2=Specific Printer.
resolution <int> 0=Default, 1=Draft, 2=Low, 3=Medium, 4=High.
trueTypeFonts <int> 0=Default, 1=Bitmap, 2=Download, 3=Substitute, 4=Outline
 

The dBLprint setPrinter method assigns the report's printer.printerSource a value of 2 (Specific printer) and printer.trueTypeFonts a value of 0 (Default).
The remaining properties are assigned values based upon the profile in use.

When the margins property is true dBLprint will interact with pageTemplate1.
Two numeric values (from the profile) are used.
The first is added to the report's pageTemplate1.marginLeft property.
The other is added to the report's pageTemplate1.marginTop property.
These additions affect the position of all displayed information.

When the streams property is true dBLprint will interact with pageTemplate1.streamFrame1.
Two numeric values (from the profile) are used.
The first is added to the report's pageTemplate1.streamFrame1.Left property.
The other is added to the report's pageTemplate1.streamFrame1.Top property.
These additions affect the position of objects displayed on pageTemplate1.streamFrame1.
The detailband, reportGroup, and other groups all reside on pageTemplate1.streamFrame1.

Back to the Top

Where is the beef (real world) ?

I have an application for Payroll.
This application prints Reports and Checks.
The Reports print jobs are Landscape.
The Checks print jobs are Portrait.

dBLprint can be used to create 2 different profiles.
One for Reports and one for Checks.

To establish a profile for "Reports".
Link the following code to a Menu item for Printer Setup (Reports).
 
set procedure to dBLprint.co additive
oRef = new dBLprint("Payroll", "Reports")
// Assign other properties as desired.
// ie: oRef.margins := true
oRef.showPrinter()
close procedure dBLprint.co

 


To establish a profile for "Checks".
Link the following code to a Menu item for Printer Setup (Checks).
 
set procedure to dBLprint.co additive
oRef = new dBLprint("Payroll", "Checks")
// Assign other properties as desired.
// ie: oRef.margins := true
oRef.showPrinter()
close procedure dBLprint.co

 

To use a profile when printing.
Code below can be used from a Menu item.
 
// Notes:
// The profile must be applied before issuing a report.render().
Local oRef, oRepo
set procedure to my.rep additive
set procedure to dBLprint.co additive
// Create report object.
oRepo = new myReport()
// Redirect report output to the Printer.
oRepo.output := 1
// Either create a dBLprint object with the "Reports" profile.
oRef  = new dBLprint("Payroll", "Reports")
// or create a dBLprint object with the "Checks" profile.
oRef  = new dBLprint("Payroll", "Checks")
// Assign other properties as desired.
// ie: oRef.margins := true
// Apply the profile to the report's printer.
oRepo.printer.parent = oRepo
oRef.setPrinter(oRepo.printer)
oRepo.printer.parent := null
// Run the report.
oRepo.render()
// Destroy objects.
oRef.release()
oRef := null
oRepo.release()
oRepo := null
close procedure dBLprint.co
close procedure my.rep

 

That's all there is !!
Best wishes to everyone when Printing dBASE Reports.

Back to the Top