Hi,
I have the folowing to enable printing a simple text line with vision x panini check scanner:
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:
[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?
DJENDER AliPosted Dec 19, 2024, 1:54 PM
Hi Jayraj Chhaya,
Thanks for fast replaying.
I did the suggested update but still same problem.
Jayraj ChhayaPosted Dec 19, 2024, 1:27 PM
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: