Search the Community
Showing results for tags 'barcode128b printwinapi.au3'.
-
I am having an extreme hard time trying to get the barcode font to work and it doesn't seem to want to. I have built this part of my code and when using a barcode reader it doesn't decode. I have tried to use the script by andybiochem and while the barcode prints and decodes fine I can't seem to include it in my script. the space I can use on the page is only 1/2 inch by 4 inches. I grabbed the formula from a site, it must be wrong, please help Func PrintBC ($barcode = "3FAFP31352R159850-D22D0468") ;Build and Print Barcode $bc = StringSplit($barcode, "") $count = 0; For $e = 0 TO UBound($bc) - 1 Local $n = $e + 1 Local $val = Asc($bc[$e]) If $val == 128 Then $val = 0 ElseIf $val >= 33 And $val <= 126 Then $val -= 32 ElseIf $val > 126 And $val <> 128 Then $val -= 50 EndIf $count += ($val * $n) Next Local $rem = Mod($count, 103) If $rem == 0 Then $rem = 128 ElseIf $rem >= 1 And $rem <= 94 Then $rem += 32 ElseIf $rem > 94 And $rem <> 0 Then $rem += 50 EndIf $check = chr($rem) $code = chr(136)&$barcode&$check&chr(138); $DESIREDFONTSIZE = 16 $hFont = _WinAPI_CreateFont((($DESIREDFONTSIZE * -20) / $TwipsPerPixelY), 0, 0, 0, $FW_NORMAL, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Code128bWin') _WinAPI_SelectObject($hPrintDc, $hFont) $OutSize = _WinAPI_GetTextExtentPoint32($hPrintDc, $code) $yTop = $yTop + 70 $Left = (($PageWidth - DllStructGetData($OutSize,"X")) / 2) $result = _WinAPI_TextOut($hPrintDc, $Left, $yTop, $code) _WinAPI_DeleteObject($hFont) ;Print BarCode Meaning $DESIREDFONTSIZE = 12 $hFont = _WinAPI_CreateFont((($DESIREDFONTSIZE * -20) / $TwipsPerPixelY), 0, 0, 0, $FW_NORMAL, False, False, False, _ $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') _WinAPI_SelectObject($hPrintDc, $hFont) $OutSize = _WinAPI_GetTextExtentPoint32($hPrintDc, $barcode) $yTop = $yTop + 60 $Left = (($PageWidth - DllStructGetData($OutSize,"X")) / 2) $result = _WinAPI_TextOut($hPrintDc, $Left, $yTop, $barcode) _WinAPI_DeleteObject($hFont) $result = _WinAPI_EndPage($hPrintDc) Next EndFunc