MemoryImageEx event

 

The MemoryImage event is received if the “Generate output in memory” option is enabled in the printer driver, and contains the image data generated by the driver. One MemoryImage event is generated for each page.

 

The MemoryImageEx event is available since Printer Version 14.98 and provides more information than the older MemoryImage event.

 

Received Parameters

PrinterName:             The name of the Printer that sent the event.

JobID                          The Windows Job ID of the print job.

DocumentName       The name of the printed document. (This parameter is provided by the printing application and it usually contains the Title of the printed document. It is not output filename of the printer driver and not the filename of the printed document.)

Data:                           The image data generated by the driver.

Size:                           Size of the image data in bytes.

 

 

The Data object can be casted to a Byte array for direct access.

Example code that casts the Data object to a Byte array and saves it to a file:

 

saveFileName = folder path and filename and extension ("path"\"filename"."file extension")

example:

                                path = c:\temp

                                file name = "random file name"

                                file extension = read from Black Ice devmode with GetFileExtension(pDevMode) function.

 

C#:

 //read file extension

32 bit:

int pdevMode = BlackIceDEVMODE.LoadBlackIceDEVMODE("Printer Name");

64 bit:

long pdevMode = BlackIceDEVMODE.LoadBlackIceDEVMODE("Printer Name");

 

string fileExt = BlackIceDEVMODE.GetFileExtension(pdevMode);       

BlackIceDEVMODE.ReleaseBlackIceDEVMODE(pdevMode);

 

 //save file

string saveFileName = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\" + Path.GetRandomFileName().Replace(".", "") + "." + fileExt;

File.WriteAllBytes(saveFileName, (byte[])Data);

 

VB.NET:  

//read file extension

32 bit:

Dim pDevMode As Integer = BlackIceDEVMODE.LoadBlackIceDEVMODE("Printer Name")

64 bit:

Dim pDevMode As Long = BlackIceDEVMODE.LoadBlackIceDEVMODE("Printer Name")

 

Dim fileExt As String = BlackIceDEVMODE.GetFileExtension(pDevMode)

BlackIceDEVMODE.ReleaseBlackIceDEVMODE(pDevMode)

 

//save file

Dim saveFileName As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\" & Path.GetRandomFileName().Replace(".", "") & "." & fileExt

File.WriteAllBytes(saveFileName, DirectCast(Data, Byte()))