Programming with the LEADTOOLS Network Virtual Printer Client Application

Take the following steps to create and run a program that uses the LEADTOOLS Network Virtual Printer Driver.

1.

Start Visual Studio 2008.

2.

From the main menu, choose File->New->Project...

3.

In the New Project dialog box, choose Visual C++ in the Projects Types, and choose Win32 Project in the Templates.

4.

Type the project name as LEADTOOLS Printer Client Demo in the Project Name field.

5.

In the Location field, use the Browse button to navigate to the Examples subdirectory (such as C:\LEAD Technologies\LEADTOOLS 19\Examples\CDLL). Uncheck both Create directory for solution and Add to Source Control options. Click OK.

6.

Click Next> in the Win32 Project Wizard.

7.

Select DLL application type. Then click Finish. Three folders will be created, entitled: "Header Files", "Resource Files", and "Source Files".

8.

From the main menu, choose Project->Properties.

9.

In the Properties dialog box, choose Configuration Properties then select C/C++ then select Preprocessor.

10.

In right side set Preprocessor definitions property to use LTVXX_CONFIG then click OK.

11.

In Solution Explorer, right-click on the Header Files folder, open stdafx.h, and add the following to the end of the file:

#include "..\..\..\include\ltPrinterClient.h"

12.

open LEADTOOLS Printer Client Demo.cpp, and add the following functions.

L_BOOL EXT_FUNCTION L_PrnClntStartup(const L_WCHAR *pszPrinterName, L_UCHAR * pbtInitialData, L_ULONG dwLenght, L_VOID ** ppUserData) 
{ 
   //set any user defined data to ppUserData 
   TCHAR * szAdditionalMessage = TEXT("additional user data"); 
   *ppUserData = malloc(_tcslen(szAdditionalMessage) * sizeof(TCHAR)); 
   memset(*ppUserData,0, _tcslen(szAdditionalMessage) * sizeof(TCHAR)); 
   memcpy(*ppUserData, szAdditionalMessage, _tcslen(szAdditionalMessage) * sizeof(TCHAR)); 
   //Function will get called as printer job starts 
   WCHAR szMessage[1024]; 
   wsprintfW(szMessage, TEXT("Job received from printer %s"), pszPrinterName); 
   MessageBox(NULL, szMessage, TEXT("Printer Client Demo"), 0); 
   return TRUE; 
} 
L_VOID EXT_FUNCTION L_PrnClntShutdown(const L_WCHAR *pszPrinterName, L_VOID * pUserData) 
{ 
   //Function will get called when job finishes 
   WCHAR szMessage[1024]; 
   wsprintfW(szMessage, TEXT("Job ended from printer %s"), pszPrinterName); 
   MessageBox(NULL, szMessage, TEXT("Printer Client Demo"), 0); 
   //free the allocated user data 
   free(pUserData); 
} 
L_BOOL EXT_FUNCTION L_PrnClntPrintJob(PRNJOBDATA* pPrintJobData, L_VOID * pUserData) 
{ 
   //Function will get called when job is being printer 
   WCHAR szMessage[1024]; 
   wsprintfW(szMessage, TEXT("Job name %s"), pPrintJobData->szPrintJobName); 
   MessageBox(NULL, szMessage, TEXT("Printer Client Demo"), 0); 
   //cast the user data to the appropriate format 
   TCHAR * szAdditionalMessage = (TCHAR*)pUserData; 
   MessageBox(NULL, szAdditionalMessage, TEXT("User additional data"), 0); 
   char *pszMessage = "Network Printer"; 
   pPrintJobData->hUserData = GlobalAlloc(GHND, strlen(pszMessage)); 
   PVOID pVoid = GlobalLock(pPrintJobData->hUserData); 
   memcpy(pVoid, pszMessage, strlen(pszMessage)); 
   GlobalUnlock(pPrintJobData->hUserData); 
   pPrintJobData->uUserDataSize = strlen(pszMessage); 
   return TRUE; 
} 

13.

Right click on LEADTOOLS Printer Client Demo project in the Solution Explorer and select Add->New Item..., and choose Module - Definition file ( .def ), and name it PrinterClient.def, add the following to it:

LIBRARY 
EXPORTS 
L_PrnClntStartup @1 
L_PrnClntShutdown @2 
L_PrnClntPrintJob @3 

14.

Compile and run the code to test it, now you need to connect the demo dll to a printer

For more information, refer to:

LEADTOOLS Network Printer Client Installer Demo.

See Also

Tutorials

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help