Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
DavidP Absent Member.
Absent Member.
3597 views

Printing Barcodes

Jump to solution

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

0 Likes
3 Solutions

Accepted Solutions
ShanePrice Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

      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.

View solution in original post

0 Likes
neidingd Honored Contributor.
Honored Contributor.

RE: Printing Barcodes

Jump to solution

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.

View solution in original post

0 Likes
TonyS Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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

View solution in original post

0 Likes
9 Replies
ShanePrice Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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.

0 Likes
DavidP Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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

Thanks,

David

0 Likes
ShanePrice Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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.

0 Likes
ShanePrice Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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.

0 Likes
DavidP Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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

0 Likes
ShanePrice Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

      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.

View solution in original post

0 Likes
DavidP Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

Shane,

    Thanks very much for this. I will try it.

David

0 Likes
neidingd Honored Contributor.
Honored Contributor.

RE: Printing Barcodes

Jump to solution

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.

View solution in original post

0 Likes
TonyS Absent Member.
Absent Member.

RE: Printing Barcodes

Jump to solution

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

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.