How to use the LEADTOOLS Network Virtual Printer - Client Application

Take the following steps to create and run a program that installs a LEADTOOLS Network Client Printer.

  1. Start Visual Studio .NET.
  2. Choose File-> New-> Project... from the menu.
  3. In the New Project dialog box, choose either "Visual C# Projects" or "VB Projects" in the Projects Type List, and choose "Class Library" in the Templates List.
  4. Type the project name as "Printer Driver Client Demo" in the Project Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK.
  5. In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference..." from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and browse to Leadtools For .NET "<LEADTOOLS_INSTALLDIR>\Bin\Dotnet\Win32 " folder and select the following DLLs:

    • Leadtools.Printer.Client.dll
  6. Add a reference to System.Windows.Forms from the .NET tab of the Add References dialog.

  7. Rename Class1.cs to MyVirtualPrinterClient.cs., and rename Class 1 to MyVirtualPrinterClient.
  8. Add the following code to the beginning of the file:

    VB
    Imports System.Windows.Forms 
    Imports Leadtools.Printer.Client.Interfaces 
                      
         

    C#
    using System.Windows.Forms 
    using Leadtools.Printer.Client.Installer; 
                                                         
         

  9. Implement the IVirtualPrinterClient interface using the following code:

    VB
    Public Class MyVirtualPrinterClient 
    Implements IVirtualPrinterClient 
                     
         

    C#
    public class MyVirtualPrinterClient : IVirtualPrinterClient 
                                       
         

  10. The created class needs to implement the three IVirtualPrinterClient methods. Open MyVirtualPrinterClient.cs and implement the following methods:

    bool IVirtualPrinterClient.Startup(string virtualPrinterName, byte[] initialData) - This function will get called by the Virtual Printer Driver at startup

    virtualPrinterName: printer name

    initialData: will hold the initialization data sent from server.

    Implement the Startup with the following code:

    VB
    Private Function Startup(ByVal virtualPrinterName As String, ByVal initialData As Byte()) As Boolean Implements IVirtualPrinterClient.Startup 
       MessageBox.Show("Job received from " & virtualPrinterName & "printer") 
       Return True 
    End Function 
                      
         

    C#
    bool IVirtualPrinterClient.Startup(string virtualPrinterName, byte[] initialData) 
    { 
       MessageBox.Show("Job received from " + virtualPrinterName + "printer"); 
       return true; 
    } 
                                       
         

    bool IVirtualPrinterClient.PrintJob(PrintJobData printJobData) - This function will be called as the print job is received by the driver.

    printJobData: contains printer data for this job

    Implement the PrintJob method using the following code:

    VB
    Private Function PrintJob(ByVal printJobData As PrintJobData) As Boolean Implements IVirtualPrinterClient.PrintJob 
       MessageBox.Show("Job data Ip Address = " & printJobData. IpAddress & " Job ID = " & printJobData.JobID) 
       'the UserData will be sent to the server machine 
       'this data can be any user specified data format 
        printJobData.UserData = New Byte() { CByte("H"c), CByte("E"c), CByte("L"c), CByte("L"c), CByte("O"c) } 
       Return True 
    End Function 
                      
         

    C#
    bool IVirtualPrinterClient.PrintJob(PrintJobData printJobData)  
    { 
       MessageBox.Show("Job data Ip Address = " + printJobData. IpAddress + " Job ID = " + printJobData.JobID); 
       //the UserData will be sent to the server machine 
       //this data can be any user specified data format 
       printJobData.UserData = new byte[] { (byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O' }; 
       return true; 
    } 
                                       
         

    void IVirtualPrinterClient.Shutdown(string virtualPrinterName) - This function will be called as a shutdown event

    virtualPrinterName: Printer name

    Implement the Shutdown method using the following code:

    VB
    Private Sub Shutdown(ByVal virtualPrinterName As String) Implements IVirtualPrinterClient.Shutdown 
       MessageBox.Show("Shutdown received for " & virtualPrinterName & " printer") 
    End Sub 
                      
         

    C#
    void IVirtualPrinterClient.Shutdown(string virtualPrinterName) 
    { 
       MessageBox.Show("Shutdown received for " + virtualPrinterName + " printer"); 
    } 
                                       
         

  11. Now the demo is ready. This Demo DLL should be installed and connected appropriately in the client machine. See the tutorial for installing a network printer client demo on a client machine(Client).
Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document