printint problem

G

grohotanie

I'm trying to print out barcodes within my program using Code128B
fonts
The code is something as follows:

strDocID = CalculateCheckSum(strDocID);
CRect rectBarcode = PrintText(pDC, rectFolder.bottom+m_nTextSpacing *
10, rect, strDocID, ALIGN_CENTER);


CString PrintContainerLabel::CalculateCheckSum(CString barcode)
{
int checkSum;
CString Code128b;

char letter;
int val = 104;
checkSum = val;

for (int i = 0; i < barcode.GetLength(); i++)
{
letter = barcode.GetAt(i);
val = letter;
val -= 32;
checkSum += val * (i + 1);
}

int moduloValue = checkSum % 103;
moduloValue += 32;

Code128b = char(202);
Code128b += barcode;
Code128b += char(moduloValue);
Code128b += char(138);

return Code128b;
}


something that I absolutely can not figure out is that it doesnt work
for "1593387" - prints out a weird character at the end of my barcode.
For any substring of this or if I add any more values, miraculously
starts working.
If anybody has any suggestions, I would greatly appreciate!
Anton
 
I

Ian Collins

I'm trying to print out barcodes within my program using Code128B
fonts
The code is something as follows:

strDocID = CalculateCheckSum(strDocID);
CRect rectBarcode = PrintText(pDC, rectFolder.bottom+m_nTextSpacing *
10, rect, strDocID, ALIGN_CENTER);
This looks like windows specific code which makes it OT here, you would
get better responses on a windows programming group.
 
J

Jim Langston

I'm trying to print out barcodes within my program using Code128B
fonts
The code is something as follows:

strDocID = CalculateCheckSum(strDocID);
CRect rectBarcode = PrintText(pDC, rectFolder.bottom+m_nTextSpacing *
10, rect, strDocID, ALIGN_CENTER);


CString PrintContainerLabel::CalculateCheckSum(CString barcode)
{
int checkSum;
CString Code128b;

char letter;
int val = 104;
checkSum = val;

for (int i = 0; i < barcode.GetLength(); i++)
{
letter = barcode.GetAt(i);
val = letter;
val -= 32;
checkSum += val * (i + 1);
}

int moduloValue = checkSum % 103;
moduloValue += 32;

Code128b = char(202);
Code128b += barcode;
Code128b += char(moduloValue);
Code128b += char(138);

return Code128b;
}


something that I absolutely can not figure out is that it doesnt work
for "1593387" - prints out a weird character at the end of my barcode.
For any substring of this or if I add any more values, miraculously
starts working.
If anybody has any suggestions, I would greatly appreciate!
Anton

Most likely your checksum calculation is wrong and for 1593387 it produces a
value outside of the barcode char set. Try taking a look at moduloValue for
ones printed correctly and ones with this "weird character".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top