How to use the barcode components with QuickReport
Usage:
  1. Put a barcode component, such as the TBarcode2D_QRCode, TBarcode2D_PDF417, and TBarcode2D_RSS14 to your form.

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

  2. Put a TQRImage or TQRGzImage control to your report.

  3. Set the Image property of the barcode component to the TQRImage or TQRGzImage control.

    You can link single TQRImage or TQRGzImage control to multiple TBarcode2D components in order to display multiple barcode symbols in the TQRImage or TQRGzImage control (using the LeftMargin and TopMargin properties to specify the position for every barcode symbol).

Note:

If the barcode symbol cannot be read, please don't reduce/stretch the barcode symbol (set the Stretch property to false). You can change the barcode symbol size by changing its Module property value.

Also, please check whether the TQRImage or TQRGzImage control is large enough to accommodate entire barcode symbol.

Note:

When using a QRImage on a quickreport sometimes it shows black on the preview as well as on the printed page. Sometimes it just shows ok. This issue can be resolved by modifying the QuickReport source code and recompiling it:

Modify print procedure, for example, procedure TQRDBImage.Print(OfsX, OfsY: Integer), replace original piece of code with:

if (DrawPict.Graphic = nil) or DrawPict.Graphic.Empty then

FillRect(Dest);

// else

with QRPrinter.Canvas do

begin

StretchDraw(Dest, DrawPict.Graphic);

StretchDraw(Dest, DrawPict.Graphic);

StretchDraw(Dest, DrawPict.Graphic);

end; //

Or save the barcode symbol to a picture file, then put it to your QuickReport report:

MyBitmap := TBitmap.Create;

try

MyBitmap.PixelFormat := pf8bit;

MyBitmap.LoadFromFile('Barcode.Bmp');

QRImage.Picture.Bitmap.Assign(MyBitmap);

finally

MyBitmap.Free;

end;

Working with DIB (Device Independant Bitmap) eliminates completely the problem. To correct the problem you need the source code of Quick report in order to rewrite the TQRImage.Print method. Here are some good hints on how to implement it:

First you need to convert bitmap to DIB

function ConvertToDiB: Boolean;

var

HeaderSize: DWORD;

ImageSize: DWORD;

LSucess: Boolean;

begin

Result := False;

begin

TBitmap(DrawPict.Graphic).IgnorePalette := False;

if TBitmap(DrawPict.Graphic).PixelFormat <> pf24bit then

  TBitmap(DrawPict.Graphic).PixelFormat := pf24bit;

GetDIBSizes(TBitmap(DrawPict.Graphic).Handle, HeaderSize, ImageSize);

HBitmapHeader := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE,HeaderSize);

BitmapHeader := pBitmapInfo(GlobalLock(HBitmapHeader));

HBitmapImage := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE,ImageSize);

BitmapImage := Pointer(GlobalLock(HBitmapImage));

LSucess := GetDIB(TBitmap(DrawPict.Graphic).Handle, 0, BitmapHeader^, BitmapImage^);

Result := LSucess;

end;

end;

Rewrite the TQRImage.Print method

StretchDIBits(QRPrinter.Canvas.Handle,

Dest.Left, Dest.Top, // Destination Origin

LWidth2, LHeight2, // Destination Size

0, 0, // Source Origin

DrawPict.Graphic.Width, DrawPict.Graphic.Height, // Source Size

BitmapImage, // Your DIB

TBitmapInfo(BitmapHeader^), DIB_RGB_COLORS, SRCCOPY);

Don't forget to free the memory

GlobalUnlock(HBitmapHeader);

GlobalFree(HBitmapHeader);

GlobalUnlock(HBitmapImage);

GlobalFree(HBitmapImage);

Contents