How to use the barcode components with FastReport

Usage:

  1. Edit your report, put a TfrxPictureView control to your report in order to present the barcode symbol.

  2. Put a barcode component, such as the TBarcode2D_QRCode, TBarcode2D_PDF417, and TBarcode2D_RSS14 to your form that the TfrxReport component is in it.

    Also, put a TDBBarcode2D component to the form and link the TBarcode2D component to the TDBBarcode2D component if the database support is required.

  3. Create the OnBeforePrint event function for the TfrxReport component.

    In the event function, change the properties of the TBarcode2D component such as Barcode, Module, and Orientation, and adjust the bitmap size of the TfrxPictureView control in order to accommodate entire barcode symbol, then use the DrawTo method of the TBarcode2D component to draw the barcode symbol to the TfrxPictureView control.

    For example:

    var

    AWidth, AHeight, ASymbolWidth, ASymbolHeight: Integer;

    begin

    Barcode2D_QRCode1.Barcode := '1235678';

    Barcode2D_QRCode1.Module := 1;

    ......

    Barcode2D_QRCode1.DrawToSize(AWidth, AHeight, ASymbolWidth, ASymbolHeight);

    with  TfrxPictureView(frxReport1.FindObject('Picture1')).Picture.Bitmap do

    begin

      Width := AWidth;

      Height := AHeight;

      Barcode2D_QRCode1.DrawTo(Canvas, 0, 0);

    end;

    end;

    Note, if you use old FastReport 2.x, please use the OnBeginBand event.

Contents