Jump to content

Recommended Posts

Posted (edited)

Barcode Printing in AU3

Some time ago I needed to print some Barcode.

Therefore I did a little research together with my friend Google.

This is what seems the easiest way to get the job done :

- Use PostScript code to generate the barcode.

- Download PrintFile to to handle the Printjob of the PostScript code : Printfile Tool

- IMORTANT Put a copy of the "prfile32.exe" in the scriptfolder and run it.

- Use AU3 to glue it together and make a nice GUI (if you want)

Barcode Sample

Barcode_Printer_Sample.au3

Image Sample

Image Printer Sample.au3

For those of you who don't know what PostScript is :

  Quote

Postscript is a programming language that was designed to specify the layout of the printed page. Postscript printers and postscript display software use an interpreter to convert the page description into the displayed graphics.

A good start learning some basics is here : PS Tutorial

In order to print the script you need to print it to PostScript printer.

But for those of you who don't have a PS printer. No worries, you can print it to a PDF printer to !!

Needles to say of course is that PS scripts are 100% compatible with PDF.

Since PostScript was developed by Adobe !!

This results in a nice side effect of this script.

Meaning that when runnng PS commands, you can create your own PDF documents as well.

Therefor I added some nice examples on how to, in the PS script example.

Give it a try and print it to a PDF printer.

(If you don"t have one, PDFCreator is a good one, see my signature somewhere)

Added a EAN13 checksum calculator

Dim $BarCode ; = "544900000043"
Dim $length
Dim $Odd, $Even, $CheckSum

; Initialize Vars
$Odd = 0
$Even = 0
$CheckSum = 0

$BarCode = InputBox("EAN13 CheckSum", "Enter 12 Digit Barcode Value", "")

$length = StringLen($BarCode)

If mod($length,2) <> 0 Then
        MsgBox(0,"Error " ,"Not a correct number of digits entered !! ")
        Exit
    Elseif int($length) <> 12 Then
        MsgBox(0,"Error " ,"Not a correct number of digits entered !! ")
        Exit
Else

    ; Calculate the Odd values
    For $i = 1 to $length Step 2
        $Odd = $Odd + (int(StringMid($BarCode,$i,1)) * 1)
    Next

    ; Calculate the Even values
    For $i = 2 to $length Step 2
        $Even = $Even + (int(StringMid($BarCode,$i,1)) * 3)
    Next

; Process result
    $Result = $Odd + $Even
    $CheckSum = 10 - mod($Result, 10)
    
    If $CheckSum = 10 Then
        $CheckSum = 0
    EndIf
        MsgBox(0,"EAN Barcode Checksum",$barcode&$CheckSum )
EndIf

Enjoy !!

regards

Edited by ptrex
  • 3 years later...
Posted

hi guy i have a question i use your Barcode_Printer_Sample.au3 ( is very best )

but i have little problem when i print i use in printer only a4 and the program have margin for letter (i suppose) how is possible change the paper format ?? thankzzz

Posted

"/PageSize [595 842]"?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

hi insert pagesize here

$PS = '%!PS-Adobe-2.0'

$PS = $PS & @CRLF & '% --BEGIN TEMPLATE--'

$PS = $PS & @CRLF

$PS = $PS & @CRLF & '% --BEGIN ENCODER ean13--'

$PS = $PS & @CRLF & '% --DESC: EAN-13'

$PS = $PS & @CRLF & '% --EXAM: 977147396801'

$PS = $PS & @CRLF & '% --EXOP: includetext guardwhitespace'

$PS = $PS & @CRLF & '% --RNDR: renlinear'

$PS = $PS & @CRLF & '/ean13 {'

$PS = $PS & @CRLF

$PS = $PS & @CRLF & ' 0 begin'

$PS = $PS & @CRLF & '/PageSize [297 420]'

but don go print blank page :)

Posted

@faustf

By my knowledge you don't specify any page size in EPS.

http://ds.dial.pipex.com/quite/eps1.htm

  Quote

The PostScript in an EPS has to follow certain rules. For instance, it shouldn't erase the page since that would affect the whole page, not just its own part. Another forbidden thing is selecting a page size,

because this would both change the size of, and erase, the whole page.

Where to print has to be calculated, starting from the 0,0 coordinates.

  Quote

The units for the graphical operations are measured in points, with 72 points per inch.

The PostScript coordinate system defines the 0 0 position to be at the lower left corner of the page,

so 72 72 is one inch from the left, and one inch up from the bottom. For a standard 8.5x11" letter-sized sheet of paper,

the upper right corner is therefore 612 792.

An A4 is W 21 x H 29.7 cm or 8.26771654 x 11.6929134 inches = W = 595,27559088 Units x H = 841,8897648 Units

Rgds,

ptrex

  • 1 month later...
Posted

hi guy i have a little problem i want insert a variable X and Y in place of dim $di = '20 750 moveto'

how can do ?? i tryed in this mode but dont go dim $di = ''&$x&$y&' moveto' and dim $di = ''&$x&''&$y&' moveto'

but dont go :oops:

  • 2 months later...
Posted

I work with barcodes professionally, it is a much more complex topic than just EAN13.

Just thought I would mention this resource, since it has not been linked in the thread:

http://code.google.com/p/postscriptbarcode/

It can't make all barcodes, but most of the common and then some. Perhaps useful to some people.

  Reveal hidden contents

I am just a hobby programmer, and nothing great to publish right now.

  • 1 year later...
  • Moderators
Posted

automaker332,

We do not accept adverts for payware apps here. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...