How to use the barcode components with Rave Reports
Usage:
  1. Use the Rave Reports Visual Designer to edit your report, put a bitmap component to your report in order to present the barcode symbol.
  2. Put a TBarcode1D barcode component, such as the TBarcode1D_Code39, TBarcode1D_EAN13, and TBarcode1D_Code128 to your form that the TRvProject component is in it.

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

  3. Insert code to call the Open method of the TRvProject component before print or preview the report, and call the Close method after print or preview the report.

    For example:

    RvProject1.Open;

    RvProject1.Execute;

    RvProject1.Close;

  4. Add RvCsStd, RvProj, and RvClass units to the uses list.
  5. Create the OnAfterOpen event function for the TRvProject component.

    In the event function, change the properties of the TBarcode1D component such as Barcode, Module, and Ratio. Then create a temporary TBitmap object, adjust its size in order to accommodate entire barcode symbol, and use the DrawTo method of the TBarcode1D component to draw the barcode symbol to the temporary TBitmap object. At last, adjust the size of the bitmap component in your report, and assign the temporary bitmap to it.

    For example:

    var

    RvReport: TRaveReport;

    RvPage : TRavePage;

    RvBitmap: TRaveBitmap;

    TmpBitmap: TBitmap;

    BarcodeWidth, BarcodeHeight, SymbolWidth, SymbolHeight: Integer;

    Scale: Integer;

    begin

    ......

    Barcode1D_Code391.Barcode := '1235678';

    Barcode1D_Code391.Module := 2;

    ......

    with RvProject1.ProjMan do

    begin

    RvReport := FindRaveComponent('Report1', nil) as TRaveReport;

    RvPage := FindRaveComponent('Page1', RvReport) as TRavePage;

    RvBitmap := FindRaveComponent('Bitmap1', RvPage) as TRaveBitmap;

    end;

    TmpBitmap := TBitmap.Create;

    try

    Barcode1D_Code391.DrawToSize(BarcodeWidth, BarcodeHeight, SymbolWidth, SymbolHeight, TmpBitmap.Canvas);

    TmpBitmap.Width := BarcodeWidth;

    TmpBitmap.Height := BarcodeHeight;

    Scale := 72;

    RvBitmap.Width := RvReport.XI2U(BarcodeWidth / Scale);

    RvBitmap.Height := RvReport.YI2U(BarcodeHeight / Scale);

    RvBitmap.MatchSide := msBoth;

    Barcode1D_Code391.DrawTo(TmpBitmap.Canvas, 0, 0);

    RvBitmap.Image.Assign(TmpBitmap);

    finally

    TmpBitmap.Free;

    end;

    ......

    end;

Contents