johnsun1976
Programmer
Hi.. I'm using a Star SP200 receipt printer and trying to format text on it..
I found this example on the printer's homepage in VB:
PRINT #1, CHR$(27); CHR$(112);
PRINT #1, "14-dot pitch font"
What I'm trying to do is this:
byte []ba = new byte[32];
h = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
ba[0] = 0x1B;
ba[1] = 0x0D;
ba[2] = 0x0A;
WriteFile(h, p, 3, &n, 0);
ba[0] = 0x70;
ba[1] = 0x0D;
ba[2] = 0x0A;
WriteFile(h, p, 3, &n, 0);
count = stob("14-dot pitch font", ba);
WriteFile(h, p, count, &n, 0);
private int stob(string str, byte []ba)
{
int i = 0;
for(i=0; (i<str.Length && i<ba.Length-2); i++)
{
ba = Convert.ToByte(str);
}
ba = 0x0D;
ba[i+1] = 0x0A;
return i+2;
}
stob is a function that take a string and return a byte array and the lengh for the parameters of WriteFile expects..
Nothing seems to happen when I print.. Does anyone know what I'm doing wrong?
Thanks
John
I found this example on the printer's homepage in VB:
PRINT #1, CHR$(27); CHR$(112);
PRINT #1, "14-dot pitch font"
What I'm trying to do is this:
byte []ba = new byte[32];
h = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
ba[0] = 0x1B;
ba[1] = 0x0D;
ba[2] = 0x0A;
WriteFile(h, p, 3, &n, 0);
ba[0] = 0x70;
ba[1] = 0x0D;
ba[2] = 0x0A;
WriteFile(h, p, 3, &n, 0);
count = stob("14-dot pitch font", ba);
WriteFile(h, p, count, &n, 0);
private int stob(string str, byte []ba)
{
int i = 0;
for(i=0; (i<str.Length && i<ba.Length-2); i++)
{
ba = Convert.ToByte(str);
}
ba = 0x0D;
ba[i+1] = 0x0A;
return i+2;
}
stob is a function that take a string and return a byte array and the lengh for the parameters of WriteFile expects..
Nothing seems to happen when I print.. Does anyone know what I'm doing wrong?
Thanks
John