Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Delphi Examples of PDF417 Encoder SDK/DLL

Delphi Examples of PDF417 Encoder SDK/DLL 4 years 4 months ago #3894

type

LPPDF417CONTEXT = ^TPDF417CONTEXT;
TPDF417CONTEXT = record
nRows : integer;
nColumns : integer;
nModuleWidth : integer;
nModuleHeight : integer;
nErrorCorrectLevel : integer;
nMargin : integer;
clForeGround : TColor;
clBackGround : TColor;
cData : array [0..7000] of char;
nSize : integer;
end;

procedure InitWorkSpace(pPdf417Ctx : LPPDF417CONTEXT ); stdcall; external 'PDF417ENCODEDLL.DLL';

function PDF417Encode2File(pPdf417Ctx : LPPDF417CONTEXT;lpImageFile :PChar) : boolean; stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417Encode2Bitmap(pPdf417Ctx : LPPDF417CONTEXT) : HBITMAP;stdcall;external 'PDF417ENCODEDLL.DLL';
function FreeWorkSpace : boolean;stdcall external 'PDF417ENCODEDLL.DLL';

function PDF417EncodeBinary2File(pBuf: PChar;nLen : Integer; pOutImage : PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): boolean;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeDigit2File(pBuf: PChar; pOutImage : PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): boolean;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeHybrid2File(pBuf: PChar;nLen : Integer; pOutImage : PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): boolean;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeText2File(pBuf: PChar; pOutImage : PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): boolean;stdcall;external 'PDF417ENCODEDLL.DLL';

function PDF417EncodeBinary2Bitmap(pBuf: PChar;nLen : Integer; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): HBITMAP;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeDigit2Bitmap(pBuf: PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): HBITMAP;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeHybrid2Bitmap(pBuf: PChar;nLen : Integer; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): HBITMAP;stdcall;external 'PDF417ENCODEDLL.DLL';
function PDF417EncodeText2Bitmap(pBuf: PChar; nRows : Integer; nColumns:Integer; nECLevel:Integer; nModuleWidth : Integer; nModuleHeight:Integer;nMargin:integer; clFore : TColor; clBack : TColor ): HBITMAP;stdcall;external 'PDF417ENCODEDLL.DLL';


procedure TForm1.btnTest1Click(Sender: TObject);
var
ctx : TPDF417CONTEXT;
s : string;
i : Integer;
pCtx : LPPDF417CONTEXT;
begin
pCtx := @ctx;
InitWorkSpace(pCtx);
ctx.nRows := strtoInt(edRows.Text);
ctx.nColumns := strtoInt(edColumns.Text);
ctx.nModuleWidth := strtoInt(edModuleWidth.Text);
ctx.nModuleHeight := strtoInt(edModuleHeight.Text);
ctx.nMargin := strtoInt(edMargin.Text);
ctx.nErrorCorrectLevel := cbECLevel.ItemIndex;
ctx.clForeGround := cbForeGround.Selected;
ctx.clBackGround := cbBackGround.Selected;
Strcopy(ctx.cData,PChar(edMemo.Text));
ctx.nSize := Length(edMemo.Text);
if edFile.Text = '' then
ShowMessage('Please input output file name')
else
begin
PDF417Encode2File(pCtx,PChar(edFile.Text));
image1.Picture.LoadFromFile(edFile.Text);
ShowMessage('Make PDF417 barcode successfully');
FreeWorkSpace();
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
ctx : TPDF417CONTEXT;
s : string;
i : Integer;
bmp : HBITMAP;
img : TBitmap;
pCtx : LPPDF417CONTEXT;
begin
pCtx := @ctx;
InitWorkSpace(pCtx);
ctx.nRows := strtoInt(edRows.Text);
ctx.nColumns := strtoInt(edColumns.Text);
ctx.nModuleWidth := strtoInt(edModuleWidth.Text);
ctx.nModuleHeight := strtoInt(edModuleHeight.Text);
ctx.nMargin := strtoInt(edMargin.Text);
ctx.nErrorCorrectLevel := cbECLevel.ItemIndex;
ctx.clForeGround := cbForeGround.Selected;
ctx.clBackGround := cbBackGround.Selected;
Strcopy(ctx.cData,PChar(edMemo.Text));
ctx.nSize := Length(edMemo.Text);
if edFile.Text = '' then
ShowMessage('Please input output file name')
else
begin
image1.Picture.CleanupInstance;
bmp := PDF417Encode2Bitmap(pCtx);
img := TBitmap.Create;
img.Handle := bmp;
image1.Picture.Assign(img);
img.Free;
ShowMessage('Make PDF417 barcode successfully');
FreeWorkSpace();
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
nRows,nColumns,nModuleWidth,nModuleHeight,nMargin,nECLevel : integer;
clBack,clFore : TColor;
sData,sFile : string;
nSize : Integer;
begin
nRows := strtoInt(edRows.Text);
nColumns := strtoInt(edColumns.Text);
nModuleWidth := strtoInt(edModuleWidth.Text);
nModuleHeight := strtoInt(edModuleHeight.Text);
nMargin := strtoInt(edMargin.Text);
nECLevel := cbECLevel.ItemIndex;
clFore := cbForeGround.Selected;
clBack := cbBackGround.Selected;
sData := edMemo.Text;
nSize := Length(edMemo.Text);
sFile := edFile.Text;
if PDF417EncodeHybrid2File(PChar(sData),nSize , PChar(sFile), nRows, nColumns, nECLevel,nModuleWidth, nModuleHeight,nMargin, clFore, clBack) then
begin
image1.Picture.LoadFromFile(edFile.Text);
ShowMessage('Make PDF417 barcode successfully');
end
else
ShowMessage('Make PDF417 barcode failed')
end;

procedure TForm1.Button3Click(Sender: TObject);
var
nRows,nColumns,nModuleWidth,nModuleHeight,nMargin,nECLevel : integer;
clBack,clFore : TColor;
sData,sFile : string;
nSize : Integer;
bmp : HBITMAP;
img : TBitmap;
begin
nRows := strtoInt(edRows.Text);
nColumns := strtoInt(edColumns.Text);
nModuleWidth := strtoInt(edModuleWidth.Text);
nModuleHeight := strtoInt(edModuleHeight.Text);
nMargin := strtoInt(edMargin.Text);
nECLevel := cbECLevel.ItemIndex;
clFore := cbForeGround.Selected;
clBack := cbBackGround.Selected;
sData := edMemo.Text;
nSize := Length(edMemo.Text);
sFile := edFile.Text;
bmp := PDF417EncodeText2Bitmap(PChar(sData), nRows, nColumns, nECLevel,nModuleWidth, nModuleHeight,nMargin, clFore, clBack);
begin
img := TBitmap.Create;
img.Handle := bmp;
image1.Picture.Assign(img);
img.Free;
ShowMessage('Make PDF417 barcode successfully');
DeleteObject(bmp);
end
end;
The administrator has disabled public write access.

  • Posts:59
  • developer's Avatar
  • developer
  • Moderator
  • OFFLINE
  • Karma: 1
  • Page:
  • 1
Time to create page: 0.169 seconds
Powered by Kunena Forum :: Wibi