Print to Memory (Memory Image) DLL VB.NET Sample

Description:

Demonstrates how to capture and save PDF, TIFF, BMP or EMF images, OCR data printed and text data printed into memory with the Black Ice ColorPlus, Color, Monochrome and EMF Printer Drivers by using the “Generate output in                 memory” , "Generate OCR output in memory" and  "Generate text output in memory" options of the printer driver for HIIPA compliant application.

 

 

 

 

How It Works:

The sample uses the WaitForPrnPipeWithPriority (Start button) and EndWaitPrnPipe (Stop button) function of the blicectr.dll.

The BLICECTR.DLL captures the pipe messages sent by the printer driver and converts them to window messages BLACKICE_MESSAGE_MEMIMAGE to be used by the application.

 

NOTE: The printer driver adds a Message Interface ID to the interface name. By default the sample and the DLL uses the Message Interface ID that is currently used by the printer driver, and the printer driver uses the Windows Session ID of the current user as the Message Interface ID. For more information about the Message Interface ID including instructions about how to change the Message Interface ID used by the printer driver, please see the following page in the manual: Message Capture – Using Messaging Interface ID

  

Logging, Changing the Settings

Edit the INI file of Sample, called SampleSettings.ini. The following option must be specified in the INI file:

[Printer Settings]

Printer Name=<Name of the Black Ice Printer>

[Print to Memory]

logfile=c:\PrinttoMemory.log

 

Description of the settings:

Printer name: Fill in the name of the Black Ice printer to be used by the Sample (without ‘<’ and ‘>’)

 

logfile: Specifies the log file’s location and name. The sample logs every messages during the printing.

  

Trying the Sample:

Open the Black Ice printer driver’s Printing Preferences window, on the File Formats tab select a suitable format (PDF, TIFF, BMP or EMF) and check the Generate output in memory box.

 

Make sure that the Messaging Interface is enabled in the Printer Driver Printing Preferences > Start Application tab:

 

 

OCR data (feature is available from version 14.98)

The sample can read the OCR data from memory, if the Generate OCR output in memory feature is enabled

The extension of the Plain Text OCR format is txt

The extension of the hOCR format is html

 

Text data (feature is available from version 14.99)

The sample can read the text data from memory, if the Generate text output in memory feature is enabled

Start the sample application and begin printing. The sample will save the image to the disk, to the location written in the sample window.

 

Sample Source Code Folder Location:

<RTK Installation Folder>\<RTK 32/64 bit>\Samples\Sample Source Codes\VB.NET\Print to Memory DLL VB.NET Sample  

 

Solution files

Compilers

Target .NET Framework

Print to Memory Dll VB.NET Sample_VS2015.sln

Visual Studio 2015

.NET Framework 4.0

Print to Memory Dll VB.NET Sample_VS2017.sln

Visual Studio 2017

.NET Framework 4.0

Print to Memory Dll VB.NET Sample_VS2019.sln

Visual Studio 2019

.NET Framework 4.0

Print to Memory Dll VB.NET Sample_VS2022.sln

Visual Studio 2022

.NET Framework 4.8

 

Additional files needed for redistribution:

-           Print to Memory DLL VB.NET Sample.exe

-           blicectr.dll

-           BlackIceDEVMODE.dll

-           SampleSettings.ini

 

These additional files are located in the following folders.

                        \BiPrnDrv

                        \BlackiceDEVMODE

                        \Samples”

 

For detailed instructions on how to create a new project, please refer to the Creating a new project that uses message capture and the print to memory feature section.

 

Note: Please make sure that you use the appropriate Resource Tool Kit, there are two different RTKs.

- API/RTK for 32/64 bit Windows 11, 10, 8.1, 7

- API/RTK for 32/64 bit Windows Server 2025/2022/2019/2016/2012 R2/2012

 

Using Message Capture and Printing from the Same Process

 

If you wish to extend the Message Capture samples with printing using AutoPrint, or otherwise combine message capture and printing in the same application, the printing thread must be separated from the message capture thread.

 

Printing and capturing messages from the same thread will result in lost BLACKICE_MESSAGE_DEVMODE messages. Other messages may appear to work, but they will be delayed. This is because BLACKICE_MESSAGE_DEVMODE messages will wait for response and eventually time out, while other messages do not wait for response and are queued.

 

Limitations:

A single instance of Printer Driver can interface with either a “Message Capture” sample application or with a “Print to Memory” sample application at the same time.