URGENT HELP Code128 barcode printing
I am having a major issue printing a readable barcode from QT on an epson M-T500 printer thermal receipt printer.
i am using the font from http://www.dafont.com/code-128.font
It prints th ebarcode but somehow its not printing the correct order
I even tried to hardcode the char with ascii code still does not work.
Any help will be much appreciated.
The Barcode text: MHB-6TG-6TG-GGHJ
My sample code:
Code:
painter.begin(&printer);
double scaleFactor;
scaleFactor = 1.0;
barcodefont.
setLetterSpacing(QFont::AbsoluteSpacing,
1.0);
painter.setFont(barcodefont);
char mytext[20];
mytext[0]= 204;
mytext[1]=77;
mytext[2]=72;
mytext[3]=66;
mytext[4]=45;
mytext[5]=54;
mytext[6]=84;
mytext[7]=71;
mytext[8]=45;
mytext[9]=54;
mytext[0]=84;
mytext[11]=71;
mytext[12]=45;
mytext[13]=71;
mytext[14]=71;
mytext[15]=72;
mytext[16]=74;
mytext[17]=104;
mytext[18]=206;
mytext[19]=0;
qDebug() << mytext;
painter.drawText(-30, 370,mytext);
painter.end();
1 Attachment(s)
Re: URGENT HELP Code128 barcode printing
I assume the '\xCC' and '\xCE' characters are a start and end marker. Your array index 10 is mistyped, and I have converted it to a QByteArray. This code:
Code:
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
// QPrinter printer;
// printer.setOutputFormat(QPrinter::PdfFormat);
// printer.setOutputFileName("test.pdf");
image.fill(1);
painter.begin(&image);
barcodefont.
setLetterSpacing(QFont::AbsoluteSpacing,
10.0);
//deliberately spread out painter.setFont(barcodefont);
qDebug() << mytext;
painter.drawText(10, 90, mytext);
painter.end();
image.save("test.png");
return app.exec();
}
produces this output (this is the PNG, but the PDF looks the same):
Attachment 6716
The characters look good here.
Re: URGENT HELP Code128 barcode printing
Thank You soo much for your help :-) Worked like a charm