FaxMan Jr
Using the Printer Control

The FaxMan Jr printer control allows your application to create a virtual FaxMan printer driver for creating fax files from print jobs. The control allows your application to see if a printer is installed, to install a printer instance and to get notifications from its associated printer that a print job has completed.

 

  1. Instantiate the Printer control
  2. Set the PrinterName property
    The PrinterName property should be set to the the name of the printer as you want it to appear in the Printer's folder.
  3. Installing the printer if needed
    Once the PrinterName property is set, your application can query the IsPrinterInstalled property to see if that printer has already been installed, if not then the application can use the control to install it.

    Before calling the InstallPrinter method the application can set the PrintFilesPath to specify the directory in which fax files will be created. InstallPrinter can then be called passing the path and name of the exe to be associated with the driver.  The exe specified here is used to startup the application when a print job is sent to the printer and the application isn't already running.
  4. Handle the PrintComplete event
    When a print job is finished, the control will fire the PrintComplete event. Your application should call the GetNextPrintJob method of the PrintJobs collection which is returned in the PrintJobs property of the printer control. The PrintJobs collection is a FIFO list of all print jobs that have been completed and not previously retrieved. The GetNextPrintJob method returns a PrintJob object which contains properties for FileName, DocumentName, Pages and Status of the print job.

 

Installing the printer driver requires Administrative rights on most operating systems. The InstallPrinter method will fail in the event the user doesnt have the appropriate rights.

 

Due to the security on Vista applications run under a limited rights scenario even if the user is logged in as an Administrative user. To run with Administrative rights the application must either be started by right clicking on the icon and selecting 'Run As Admin' or by embedding a Vista Manifest in the executable. In both cases Vista will still display a UAC dialog confirming the user wants to run the application as Admin.

 

To run the command line as administrator:
Click on Start or press the Windows Key, type cmd, but this time, don't press Enter, instead,
press CTRL+SHIFT+Enter. You'll be prompted to approve the action,
if successful the dialog title will start with "Administrator:"

 

For this reason we recommend that if you plan to support Vista that you install your FaxMan printer driver instance from your application's installer which should already be running as Admin. This way your application can run under the limited user account and the printer will already be installed.

Using the Printer Control in C#

 

FaxPrint print;

...

print = new FaxPrint();

print.PrinterName = "My Fax Printer";

if( !print.IsPrinterInstalled )

print.InstallPrinter( Application.ExecutablePath );

print.PrintComplete += new DataTech.FaxManNet.FaxPrint.__Delegate_PrintComplete(print_PrintComplete);

...

private void print_PrintComplete()

{

   PrintJob job = print.PrintJobs.GetNextPrintJob();

   string file = job.FileName;

   // The faxfile has been created and can be sent now

}

 

Using the Printer Control in VB.Net

Dim print As FaxPrint

...

print = New FaxPrint()

print.PrinterName = "My Fax Printer"

If (Not print.IsPrinterInstalled) Then
    print.InstallPrinter(Application.ExecutablePath)
End If

print.PrintComplete += New DataTech.FaxManNet.FaxPrint.__Delegate_PrintComplete(print_PrintComplete)

...

Private Sub print_PrintComplete()
   Dim job As PrintJob = print.PrintJobs.GetNextPrintJob()

   Dim file As String = job.FileName

   ' The faxfile has been created and can be sent now

End Sub

 

 


© 2014 Data Techniques, Inc. All Rights Reserved.

Send comments on this topic.