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 TBarcode2D barcode component, such as the TBarcode2D_QRCode, TBarcode2D_PDF417, and TBarcode2D_RSS14 to your form that the TRvProject 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. 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 TBarcode2D component such as Barcode, Module, and Orientation. Then create a temporary TBitmap object, adjust its size in order to accommodate entire barcode symbol, and use the DrawTo method of the TBarcode2D 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;

    AWidth, AHeight, ASymbolWidth, ASymbolHeight: Integer;

    Scale: Integer;

    begin

    ......

    Barcode2D_QRCode1.Barcode := '1234567890';

    Barcode2D_QRCode1.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

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

    TmpBitmap.Width := AWidth;

    TmpBitmap.Height := AHeight;

    Scale := 72;

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

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

    RvBitmap.MatchSide := msBoth;

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

    RvBitmap.Image.Assign(TmpBitmap);

    finally

    TmpBitmap.Free;

    end;

    ......

    end;

Contents