Jump to content



Photo

Barcode Printing in AU3


  • Please log in to reply
14 replies to this topic

#1 ptrex

ptrex

    Universalist

  • MVPs
  • 2,400 posts

Posted 30 March 2008 - 08:38 PM

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
Attached File  Barcode_Printer_Sample.au3   30.59KB   1329 downloads

Image Sample
Attached File  Image Printer Sample.au3   3.09KB   361 downloads

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

AutoIt         
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, 14 September 2012 - 09:26 AM.








#2 icadea

icadea

    Prodigy

  • Active Members
  • PipPipPip
  • 159 posts

Posted 31 March 2008 - 01:19 PM

thanks for the example, this is great. :)

#3 ptrex

ptrex

    Universalist

  • MVPs
  • 2,400 posts

Posted 06 April 2008 - 07:05 PM

@all

Added a EAN13 checksum calculator.

See first post.

Regards,

ptrex

#4 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 13 January 2012 - 01:45 PM

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

#5 water

water

    ?

  • MVPs
  • 11,168 posts

Posted 13 January 2012 - 01:53 PM

"/PageSize [595 842]"?

UDFs:

Active Directory (2012-10-12 - Version 1.3.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

OutlookEX (2012-10-07 - Version 0.9.0.0 released) - Download - General Help & Support - Example Scripts - Wiki

ExcelChart (2013-01-21 - Version 0.3.1.1 released) - Download - General Help & Support - Example Scripts

WordEX (2012-12-29 - Version 1.3 released) - Download

ExcelEX (2013-05-11 - Alpha 4 released) - Download


#6 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 13 January 2012 - 03:24 PM

where i try to find , but tell me pagesize dont exist

#7 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 13 January 2012 - 05:30 PM

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

#8 ptrex

ptrex

    Universalist

  • MVPs
  • 2,400 posts

Posted 13 January 2012 - 07:40 PM

@faustf

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

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

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


Rgds,
ptrex

#9 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 16 January 2012 - 06:13 PM

how is possble move rectangle ???

#10 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 16 January 2012 - 06:13 PM

and is possble insert little jpg ???

#11 ptrex

ptrex

    Universalist

  • MVPs
  • 2,400 posts

Posted 16 January 2012 - 07:10 PM

@faustf

Best start reading here : http://paulbourke.net/dataformats/postscript/

Rgds,
ptrex

#12 ptrex

ptrex

    Universalist

  • MVPs
  • 2,400 posts

Posted 18 January 2012 - 12:57 PM

@faustf

Add Image Printer Sample.au3 to the first post.

Someone might find it usefull

Rgds
ptrex

#13 faustf

faustf

    Polymath

  • Active Members
  • PipPipPipPip
  • 240 posts

Posted 07 March 2012 - 11:01 PM

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:

#14 AdamUL

AdamUL

    Prodigy

  • Active Members
  • PipPipPip
  • 168 posts

Posted 08 March 2012 - 03:21 PM

You have an extra "&" at the beginning. Try:
$di = $x & ' ' & $y & ' moveto'



Adam

#15 Myicq

Myicq

    Prodigy

  • Active Members
  • PipPipPip
  • 183 posts

Posted 21 May 2012 - 12:35 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users