Taking into account that it is enough to add the functionality of generating barcode and PDF417 format with "PDF417Lib", it follows toturial:
There is no need to install dpk that comes along unless you want to implement something at design time.
First step is to add the following directories in the project search path (Ctrl + Shift + F11):
...\pas417lib-master\vcl
...\pas417lib-master\src
Now it follows the code of the classes that implemented:
BarcodeGenerator - Interface
unit BarcodeGenerator;
interface
uses
Graphics;
type
IBarcodeGenerator = interface
['{BDBF2DC5-29CB-413F-9920-579D4213B638}']
function GetPdf417(AValue: String): TBitmap;
end;
implementation
end.
BarcodeGeneratorImpl - Implementation
unit BarcodeGeneratorImpl;
interface
uses
Graphics, PDF417Barcode, BarcodeGenerator;
type
TBarcodeGeneratorImpl = class(TInterfacedObject, IBarcodeGenerator)
private
MyCodeBar: TPDF417BarcodeVCL;
public
constructor Create;
destructor Destroy; override;
function GetPdf417(AValue: String): TBitmap;
end;
implementation
uses
SysUtils;
{ THelperBarcodeGenerator }
constructor TBarcodeGeneratorImpl.Create;
begin
MyCodeBar := TPDF417BarcodeVCL.Create(nil);
end;
destructor TBarcodeGeneratorImpl.Destroy;
begin
FreeAndNil(MyCodeBar);
inherited;
end;
function TBarcodeGeneratorImpl.GetPdf417(AValue: String): TBitmap;
begin
MyCodeBar.Lines.Add(AValue);
Result := MyCodeBar.Bitmap;
end;
end.
Now in this example, a normal unit was created, with the visual part, a TEdit, a TImage and a TButton were added.
Usage example
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
end;
var
Form2: TForm2;
implementation
uses
BarcodeGenerator, BarcodeGeneratorImpl;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
FBarcodeGenerator: IBarcodeGenerator;
begin
FBarcodeGenerator := TBarcodeGeneratorImpl.Create;
Image1.Picture.Bitmap := FBarcodeGenerator.GetPdf417(Edit1.Text);
end;
end.
I think with the 2 units BarcodeGenerator and BarcodeGeneratorImpl, it's easy for you to inject this function into your framework.