Jump to content
Sign in to follow this  

Barcode Printing in AU3

Recommended Posts

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


Image Sample

Image Printer Sample.au3

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

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 !! ")
    Elseif int($length) <> 12 Then
        MsgBox(0,"Error " ,"Not a correct number of digits entered !! ")

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

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

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

Enjoy !!


Edited by ptrex

Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

"/PageSize [595 842]"?

My UDFs and Tutorials:


Active Directory (2018-12-03 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-03-02 - Version - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-01-22 - Version - Download - General Help & Support
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


Share this post

Link to post
Share on other sites

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 :)

Share this post

Link to post
Share on other sites


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


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.

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



Share this post

Link to post
Share on other sites

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:

Share this post

Link to post
Share on other sites

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:


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

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

Share this post

Link to post
Share on other sites


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


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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


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  

  • Create New...