Hi,
I have the folowing to enable printing a simple text line with vision x panini check scanner:
C#
if (OnLine(DeviceId))
{
...
...
LOGFONT font = new LOGFONT();//struct in default (all to 0)
if (!SendPrinterData(DeviceId, 0, font, "PRINTING TEST", 20, NULL, 0, 0))
{
StringBuilder erStrPrinter = new(200);
if (GetEngineApiErrorString(ref erStrPrinter, 200))
{
SendScannerLog("PRINTER_EXCEPTION: " + erStrPrinter.ToString());
Trace.WriteLine(erStrPrinter.ToString());
}
}
if (!StartFeeding(DeviceId))
{
...
...and here is the SendPrinterData() function signature with the font struct:
C#
[DllImport("VisionAPI.dll", EntryPoint = "?SendPrinterData@@YGHKKUtagLOGFONTA@@PADK1KK@Z", CharSet = CharSet.Unicode)]
public static extern bool SendPrinterData(uint DeviceId, uint Head, LOGFONT lf, string? strToPrint, uint strToPrintOffSet, string? imgPath, uint imgOffSet, uint imgSrcType);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct LOGFONT
{
public const int LF_FACESIZE = 32;
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LF_FACESIZE)]
public string lfFaceName;
}Things to know:
- The use of the function SendPrinterData() is done according to the documentation from Panini VISION X company.
- When executed, SendPrinterData() returns true, so it should work normally (the text in the function should be printed on one face on the check), but here nothing happens and no error rising.
- The rest of my app works correctly (a wpf app).
- There is a demo app provided by Panini VISION X company and it works with it.
What have i done wrong?

Jayraj ChhayaRank #304 · 8.2K reputationPosted Dec 19, 2024, 8:27 AM EST
Hi DJENDER Ali,
The potential cause of the issue lies in the initialization of the
LOGFONTstructure. TheLOGFONTstructure is crucial for defining the font properties for the text to be printed. In the current implementation, theLOGFONTstructure is instantiated but not populated with any meaningful values. Specifically, thelfFaceNamefield, which specifies the font name, is left uninitialized. This could lead to the printer not recognizing the font settings, resulting in no output.To resolve this issue, you need to properly initialize the
LOGFONTstructure with appropriate values before passing it to theSendPrinterData()function. Here’s an updated version of the code snippet with the necessary modifications:if (OnLine(DeviceId)) { LOGFONT font = new LOGFONT { lfHeight = 20, // Set the desired height lfWidth = 0, // Default width lfWeight = 400, // Normal weight lfItalic = 0, // Not italic lfUnderline = 0, // Not underlined lfStrikeOut = 0, // Not struck out lfCharSet = 1, // Default character set lfOutPrecision = 0, // Default output precision lfClipPrecision = 0, // Default clipping precision lfQuality = 0, // Default quality lfPitchAndFamily = 0, // Default pitch and family lfFaceName = "Arial" // Set a valid font name }; if (!SendPrinterData(DeviceId, 0, font, "PRINTING TEST", 20, null, 0, 0)) { StringBuilder erStrPrinter = new(200); if (GetEngineApiErrorString(ref erStrPrinter, 200)) { SendScannerLog("PRINTER_EXCEPTION: " + erStrPrinter.ToString()); Trace.WriteLine(erStrPrinter.ToString()); } } if (!StartFeeding(DeviceId)) { // Handle feeding error } }DJENDER Ali54 reputationPosted Dec 19, 2024, 8:54 AM EST
Hi Jayraj Chhaya,
Thanks for fast replaying.
I did the suggested update but still same problem.