L_PrnRegisterEMFCallback

#include "Ltprinter.h"

L_LTPRINTER_API L_INT EXT_FUNCTION L_PrnRegisterEMFCallback(pszPrinterName, fnEMFCallback, pData)

Registers and enables the firing of the EMF callback function.

Parameters

L_TCHAR * pszPrinterName

Character string that contains the name of the LEADTOOLS Virtual Printer Driver.

PRNEMFRGSPROC fnEMFCallback

Callback function to be registered. This callback function gets the printed job as an EMF data file.

L_VOID * pData

Void pointer that you can use to pass one or more additional parameters that the callback function(s) needs.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Initialize the COM library by calling the CoInitialize Windows C API before using callbacks. After you are finished using the callbacks release the COM library by calling the CoUninitialize Windows C API.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT EXT_CALLBACK OnEmfRgsProc(L_WCHAR * pszPrinter, 
                                HGLOBAL hMem, 
                                L_UINT  uSize, 
                                L_VOID * pData) 
{ 
   UNREFERENCED_PARAMETER(pszPrinter); 
   UNREFERENCED_PARAMETER(pData); 
 
   static L_INT nCounter = 0; 
   HANDLE hFile = INVALID_HANDLE_VALUE; 
   DWORD  uSizeWritten = 0; 
   L_UCHAR * pEmfData= (L_UCHAR*) GlobalLock( hMem ); 
 
   L_TCHAR szFileName[MAX_PATH]; 
   L_TCHAR szPathDir[MAX_PATH]; 
 
   GetTempPath(MAX_PATH,szPathDir); 
 
   GetTempFileName(szPathDir,TEXT("AnyName"),0,szFileName); 
 
   if( pEmfData ) 
   { 
      hFile = CreateFile( szFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); 
      if( hFile != INVALID_HANDLE_VALUE ) 
      { 
         WriteFile( hFile, pEmfData, uSize, & uSizeWritten, NULL ); 
         CloseHandle( hFile ); 
 
         HENHMETAFILE hMetaFile = GetEnhMetaFile(szFileName); 
 
         // 
         // Do what ever you need in hMetaFile then delete it 
         // 
 
         DeleteEnhMetaFile(hMetaFile); 
      } 
      GlobalUnlock( hMem ); 
   } 
   // Don't forget freeing the mem. 
   GlobalFree( hMem ); 
 
   return 1; 
} 
 
L_INT RegistrationEMFCallback() 
{ 
   int nRet = L_PrnRegisterEMFCallback(TEXT("TEST LEADTOOLS Printer"),OnEmfRgsProc,NULL); 
 
   if(nRet == SUCCESS) 
   { 
      L_PrnUnRegisterEMFCallback(TEXT("TEST LEADTOOLS Printer")) ; 
   } 
 
   return nRet; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Virtual Printer C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.