Sign in to follow this  
Followers 0
blenkhn

using barcode font code128b and printing with printwinapi.au3

10 posts in this topic

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

Share this post


Link to post
Share on other sites



Look at OPENBARCODES project

http://grandzebu.net/informatique/codbar-en/codbar.htm

I sucessfully implemented barcodes (all types) based on this in our big work project.

Share this post


Link to post
Share on other sites

Great project, I'm trying to implement it with autoit, can you share some code?

I will post some code translated to PowerBuilder syntax which is very similar to AutoIt ...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I will post some code translated to PowerBuilder syntax which is very similar to AutoIt ...

Here it is:

In ZIP archive there are these functions:

uf_barcode_128.srf
uf_barcode_128_testnum.srf
uf_barcode_25i.srf
uf_barcode_39.srf
uf_barcode_ean13.srf
uf_barcode_ean8.srf

These functions are translated from original Pascal sources to PowerBuilder syntax which is very similar to AutoIt.

Now I stripped some headers and translated my original Czech comments/variable names to English.

To use these functions just install barcode fonts available on original site http://grandzebu.net/informatique/codbar-en/codbar.htm

and set desired barcode font to label control on your GUI.

Then pass original (barcode) text to one of these functions and set result to label by GUICtrlSetData() which show result as barcode rectangles.

I don't need barcodes in AutoIt so I didn't translate it to AutoIt myself.

But I can help with translating these functions to AutoIt but now I can't do it all myself because lack of free time.

BARCODE_powerbuilder.zip

Edited by Zedna
1 person likes this

Share this post


Link to post
Share on other sites

Here it is:

In ZIP archive there are these functions:

uf_barcode_128.srf
uf_barcode_128_testnum.srf
uf_barcode_25i.srf
uf_barcode_39.srf
uf_barcode_ean13.srf
uf_barcode_ean8.srf

These functions are translated from original Pascal sources to PowerBuilder syntax which is very similar to AutoIt.

Now I stripped some headers and translated my original Czech comments/variable names to English.

To use these functions just install barcode fonts available on original site http://grandzebu.net/informatique/codbar-en/codbar.htm

and set desired barcode font to label control on your GUI.

Then pass original (barcode) text to one of these functions and set result to label by GUICtrlSetData() which show result as barcode rectangles.

I don't need barcodes in AutoIt so I didn't translate it to AutoIt myself.

But I can help with translating these functions to AutoIt but now I can't do it all myself because lack of free time.

Thank you!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

New version:

- all functions translated to AutoIt

Available functions:

barcode_128()
barcode_ean8()
barcode_ean13()
barcode_25i()
barcode_39()
Edited by Zedna

Share this post


Link to post
Share on other sites

This font tool is able to create code128 with a font and print barcode.

Share this post


Link to post
Share on other sites

Why not choose some other barcode generator?

According to my experience, I like to use the following barcode creating, you can generate any barcode type.

It empowers users with the ability to include an image viewer and pre-processing capabilities such as deskew, despeckle, and annotations alongside barcode reading & writing functionalities.

You could integrate your Document Imaging applications, most common 1D, postal and 2D barcodes can be created with VB.NET and C#.NET codes, including UPC/EAN, Code 128, Code 39, GS1-128, Interleaved 2 of 5, Standard (Industrial) 2 of 5, Code 11 (USD-8), Australia Post 4-state Barcode, Royal Mail (RM4SCC), USPS Intelligent Mail, USPS POSTNET, USPS PLANET, Data Matrix, PDF417, MicroPDF417, QR Code, and Micro PDF-417 and more. More than 90 document formats such Bitmap, Metafile and PDF are provided for saving generated barcode images into stream, file, http, ftp...

Hope this can help you.

It seems that it is not free to use.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0