FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Postal bar code
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Postal bar code
Posted: Mon Oct 17, 2022 11:43 PM

In the U.S., we need to print a barcode for the full zipcode below the address.

This requires a specific font. I can print a barcode but it is not at all like what I need to use.

I looked at the sample programs, but I use the printer class directly ( not the command lines ), and I have "sort of" translated it to work, but again the output is not correct.

Has anyone used the oPrn:PrintBarCode( ) Method for doing this with mailing labels ?

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Postal bar code
Posted: Tue Oct 18, 2022 07:26 AM
Inside samples BarCod01.

Code (fw): Select all Collapse
function PrintBarCodes()

   local oPrn, oFont

   PRINT oPrn PREVIEW
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 OF oPrn

   PAGE

   @ 1, 1 PRINT TO oPrn TEXT "PDF417" INCHES FONT oFont

   @ 1.25, 1 PRINT TO oPrn TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
      AS BARCODE TYPE "PDF417" SIZE 4, 0.75 INCHES

   @ 3.00, 1 PRINT TO oPrn TEXT cName    INCHES FONT oFont
   @ 3.30, 1 PRINT TO oPrn TEXT cCity    INCHES FONT oFont
   @ 3.60, 1 PRINT TO oPrn TEXT cCountry INCHES FONT oFont
   @ 3.90, 1 PRINT TO oPrn TEXT cItem    INCHES FONT oFont

   @ 3.00,5.00 PRINT TO oPrn TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
      AS BARCODE TYPE "QR-CODE" SIZE 1.2,1.2 INCHES

   @ 5.5, 1 PRINT TO oPrn TEXT TRIM( cName ) ;
      AS BARCODE TYPE "CODE128" SIZE 4,1 INCHES

   @ 9, 4 PRINT TO oPrn TEXT cItem AS BARCODE TYPE "EAN13" ;
      SIZE 4,1 INCHES

   ENDPAGE

   ENDPRINT

   RELEASE FONT oFont

return nil
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Postal bar code
Posted: Tue Oct 18, 2022 07:42 AM

Sorry Tim,

It's not the method version I see now .....

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Postal bar code
Posted: Tue Oct 18, 2022 01:21 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Postal bar code
Posted: Tue Oct 18, 2022 01:53 PM
// C:\FWH..\SAMPLES\FWBARCOD.PRG - By Nages.

Code (fw): Select all Collapse
#Include "FiveWin.ch"

#define PAD_LEFT            0
#define PAD_RIGHT           1
#define PAD_CENTER          2

STATIC oWnd

FUNCTION Main()

   LOCAL oBar

   DEFINE WINDOW oWnd TITLE "Printing Barcode"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION printbarcode()

   SET MESSAGE OF oWnd TO "Printing Barcode" NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd

   RETURN NIL

FUNCTION PrintBarcode()

   LOCAL oPrn, oBarcode, oFont
   LOCAL cText := "FiveTechSoft"

   cText := "15140803532877000111550020000018651000018657"

   PRINT oPrn PREVIEW

      DEFINE FONT oFont NAME "Arial" SIZE 0, -16 BOLD OF oPrn

      oPrn:SetPage(9)    // A4
      // oPrn:SetPortrait() // Vertical
      oPrn:SetLandScape()

      PAGE

         oPrn:cmSay( 2.0,  10.5, cText, oFont,,CLR_BLACK,,PAD_CENTER  )

         oBarCode := FWER_BarCode():New( oPrn:hDCOut, cText, 700, 100, 3000, 400, 3 )

         WITH OBJECT oBarCode

            :nBCodeType    := 3  // CODE 128
            :nPinWidth     := 10
            :ShowBarCode()

         END

      ENDPAGE

   ENDPRINT

RETURN nil

// FIN / END


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Postal bar code
Posted: Wed Oct 19, 2022 06:38 PM

Thanks for responding, but the output is not correct.

U.S. mail barcodes are very specific. They use a special font, and are much thinnner than the output we are achieving with the FW barcode functions/methods.

My label printer software automatically adds them. Microsoft Word also adds them in their mailing program. I've been researching the topic, and know, for example, they are doable in C++, but have not yet attained a solution.

Essentially, the codes are equal in height to a standard print line in a letter.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Postal bar code
Posted: Wed Oct 19, 2022 06:57 PM

Dear Tim, Ask at the North American Post Office, if the Code is Two-Dimensional Datamatrix 2D??

Estimado Tim, Pregunte en la oficina de correos de América del Norte si el código es bidimensional Datamatrix 2D?

Thanks

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Postal bar code
Posted: Mon Jan 02, 2023 05:33 PM

Tim,

Check out the "USPS Barcode FAQ & Tutorial" here:

barcodefaq.com/usps-postal/

I have never used postal barcodes, so I can't offer any help with this.

I hope you have already solved your problem.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Postal bar code
Posted: Tue Jan 03, 2023 07:25 PM

James,

I checked it out, but was not able to print out the proper sized code. It was not critical, so I just moved on.

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit

Continue the discussion