Printing Barcodes

Does anyone have a good example of printing a bar code on a laser printer using Win$printer or PCL embedded commands?

I have a regular invoice and would like to print a bar code on this invoice. 

Thanks in advance,

David

  • We use the free Code 3of9 barcode font you can download from www.barcodesinc.com/free-barcode-font.  We print sheets of barcode labels (3x10).  To get the barcode to print where we wanted it to consistently across the page, we had to use WPRTUNITS-CENTIMETERS-ABS for the WINPRINT-COL-UNITS.

  • Do you have an example of what the escape sequences would be that you would send to the printer?

    Thanks,

    David

  • We don't use escape sequences.  We load the barcode font, move it to the WPRTDATA-FONT, set the column and write the print line.

  • Here's the main part of the logic...

              INITIALIZE WINPRINT-DATA, WINPRINT-COLUMN.

              MOVE BARCODE-30-FONT TO WPRTDATA-FONT.

              CALL "WIN$PRINTER"

                 USING WINPRINT-SET-FONT, WINPRINT-DATA.

              CALL "WIN$PRINTER"

                 USING WINPRINT-SET-DATA-COLUMNS, 1, 16, 31.

              MOVE 1 TO WINPRINT-TRANSPARENCY.

              MOVE WPRTUNITS-CENTIMETERS-ABS TO WINPRINT-COL-UNITS.

              MOVE WPRTALIGN-LEFT TO WINPRINT-COL-ALIGNMENT.

              ADD 1.4 TO WS-OFFSET GIVING WINPRINT-COL-START.

              CALL "WIN$PRINTER"

                 USING WINPRINT-SET-PAGE-COLUMN, WINPRINT-COLUMN.

                    STRING

                          "*"                 DELIMITED BY SIZE

                          WS-BAR-ITEM(SUB)    DELIMITED BY SIZE

                          "*"                 DELIMITED BY SIZE

                       INTO PRINT-LINE

                       ON OVERFLOW CONTINUE

                    END-STRING

              WRITE PRINT-LINE BEFORE ADVANCING 1 LINE.

              CALL "WIN$PRINTER" USING WINPRINT-CLEAR-DATA-COLUMNS.

              CALL "WIN$PRINTER" USING WINPRINT-CLEAR-PAGE-COLUMNS.

    Then we change back to our text font and print the translation of what's encoded in the barcode.

              INITIALIZE WINPRINT-DATA, WINPRINT-COLUMN.

              MOVE TEXT-30-FONT TO WPRTDATA-FONT.

              CALL "WIN$PRINTER"

                 USING WINPRINT-SET-FONT, WINPRINT-DATA.

  • Thank you very much for this information.

    Is BARCODE-30-FONT a field that holds the actual name of the font you are using?

    Is  WS-BAR-ITEM(SUB) the field you want the font to create as a bar code?

    What is the actual picture of WS-BAR-ITEM?

    Thanks,

    David

  • Verified Answer

          77  BARCODE-30-FONT        HANDLE OF FONT VALUE NULL.

          01  WS-BAR-ITEM    PIC X(13) OCCURS 5 TIMES.

    The program allows for labels to be printed on either 3x10 or 5x10 pre-gummed laser compatible label sheets.  The labels are for books, music, videos and gifts.  The barcodes are ISBN13 (13 bytes) or UPC (12 bytes).  If you need a bigger barcode, just expand he size of the picture.

    Near the beginning of the program, we load the font:

              initialize wfont-data, barcode-30-font.

              move zeroes to font-status.

              move "Free 3 of 9 Regular" to wfont-name.

              move BARCODE-30-FONT-SIZE to wfont-size.

              set WFONT-BOLD to false.

              set WFDEVICE-WIN-PRINTER to true.

              set WFCHARSET-DEFAULT to true.

              call "W$FONT"

                 using WFONT-GET-FONT, BARCODE-30-FONT, WFONT-DATA

                 giving FONT-STATUS

              end-call.

    Before we exit the program, we destroy the font:

              IF BARCODE-30-FONT NOT = NULL

                 DESTROY BARCODE-30-FONT.

  • Shane,

        Thanks very much for this. I will try it.

    David

  • Verified Answer

    if you take another Font then in this example don't forget that when e Checksum is needed for the Barcode you have to calculate it for your own!

    In the Example from Shane it is very easy because Code 39 only needs * at the beginning and the end from you Barcode String.

  • Verified Answer

    MBARCODE.zipSee attached - a subroutine that returns the necessary PCL print lines which you then simply add to your