Barcode Image?
I am using a non-graphic interface, for the most part, to allow a client to
control certain aspects of how a report prints. I would like to give them
the ability to change the format of the barcode that will print on the
report. I would love to be able to show the client what the barcode will
look like without them actually being in the report designer. I know how to
set the properties of a "hardcoded" TppBarcode component but I need to know
how to export the resulting barcode as a bitmap or something that I can
display to the customer outside of the report designer.
Thanks All,
Branden
control certain aspects of how a report prints. I would like to give them
the ability to change the format of the barcode that will print on the
report. I would love to be able to show the client what the barcode will
look like without them actually being in the report designer. I know how to
set the properties of a "hardcoded" TppBarcode component but I need to know
how to export the resulting barcode as a bitmap or something that I can
display to the customer outside of the report designer.
Thanks All,
Branden
This discussion has been closed.
Comments
You can use the AsMetaFile routine of the barcode drawcommand(s) to retrieve
the image representation that will be drawn to the report.
TppDrawBarCode.AsMetaFile;
TppDraw2DBarCode.AsMetaFile;
You could create the drawcommands manually in code, assigning the proper
values to return the desired barcode image. Take a look at the
TppCustomBarCode.PropertiesToDrawCommand for an idea of which properties
need to be set in order to properly create a barcode drawcommand.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
working syntax error free, but the resulting WMF image file is just a blank
image 1209 pixels wide by 23 pixels tall. ppBarcode1 is a barcode component
that I have already put into a report component called repBarc.
procedure TfrmTest.ButtonClick(Sender: TObject);
var
lMetaFile: TMetafile;
lDrawBarCode: TppDrawBarCode;
begin
lDrawBarCode := TppDrawBarCode.Create(Self);
with ppBarcode1 do
begin
{create print object}
lDrawBarCode.Alignment := Alignment;
lDrawBarCode.AddOnCode := AddOnCode;
lDrawBarCode.AutoEncode := AutoEncode;
lDrawBarCode.AutoSizeFont := AutoSizeFont;
lDrawBarCode.BarCodeType := BarCodeType;
lDrawBarCode.BarColor := BarColor;
lDrawBarCode.BarWidth := Trunc(BarWidth);
lDrawBarCode.BearerBars := BearerBars;
lDrawBarCode.CalcCheckDigit := CalcCheckDigit;
lDrawBarCode.Color := Color;
lDrawBarCode.Data := Data;
lDrawBarCode.CodeOK :=
IsValidBarcodeData(BarCodeType,lDrawBarCode.Data,CalcCheckDigit);
lDrawBarCode.Font := Font;
lDrawBarCode.Orientation := Orientation;
lDrawBarCode.PrintHumanReadable:= PrintHumanReadable;
lDrawBarCode.Transparent := Transparent;
lDrawBarCode.WideBarRatio := WideBarRatio;
{set size last}
lDrawBarCode.Left := 0;
lDrawBarCode.Top := 0;
{calc height and width - do this last}
lDrawBarCode.Height := mmHeight;
if mmWidth > 0 then
lDrawBarCode.Width := mmWidth
else
lDrawBarCode.Width := trunc(lDrawBarCode.Height * (Width/Height));
lDrawBarCode.CalcDrawCommandSize(repBarc.Printer);
end;
lMetaFile := lDrawBarCode.AsMetaFile;
lMetaFile.SaveToFile('C:\temp.wmf');
lDrawBarCode.Free;
lMetaFile.Free;
end;
I'm not sure what I'm doing wrong here?
Thank you,
Branden
This took me a while to figure out .
The TppDrawBarCode.BarWidth property expects an integer in mmthousandths
(micron) units so basically you are getting a barcode with bar widths of 0.
Try replacing that line with the following after adding ppUtils and ppTypes
to your uses clause.
lDrawBarCode.BarWidth := ppToMMThousandths(ppBarcode1.BarWidth,
ppReport1.Units, pprtHorizontal, ppReport1.Printer);
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thank you for all the help,
Branden Johnson