Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/fpdf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ TFPDF = class
(000, 000, 128), (000, 000, 255), (000, 128, 128), (000, 255, 255),
(220, 220, 220) );

function SwapBytes(Value: LongWord): LongWord; overload;
function SwapBytes(Value: Cardinal): Cardinal; overload;
function SwapBytes(Value: Word): Word; overload;
function Split(const AString: string; const ADelimiter: Char = ' '): TStringArray;
function CountStr(const AString, SubStr : String ) : Integer ;
Expand Down Expand Up @@ -3560,7 +3560,7 @@ function TFPDF.GzDecompress(const StrIn: AnsiString): AnsiString;
end;
end;

function SwapBytes(Value: LongWord): LongWord;
function SwapBytes(Value: Cardinal): Cardinal;
type
Bytes = packed array[0..3] of Byte;
begin
Expand Down
31 changes: 27 additions & 4 deletions source/fpdf_ext.pas
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ TFPDFExt = class(TFPDF)
BarHeight: double = 0; BarWidth: double = 0);

{$IfDef DelphiZXingQRCode}
procedure QRCode(vX: double; vY: double; const QRCodeData: String;
DotSize: Double = 0; AEncoding: TQRCodeEncoding = qrAuto);
function QRCode(vX: double; vY: double; const QRCodeData: String;
DotSize: Double = 0; AEncoding: TQRCodeEncoding = qrAuto): double; overload;
procedure QRCode(vX: double; vY: double; vQRCodeSize: double;
const QRCodeData: String; AEncoding: TQRCodeEncoding = qrAuto); overload;
{$EndIf}
procedure Draw2DMatrix(AMatrix: TFPDF2DMatrix; vX: double; vY: double;
DotSize: Double = 0);
Expand Down Expand Up @@ -1528,8 +1530,27 @@ procedure TFPDFExt.Code128(const ABarCode: string; vX: double; vY: double;
end;

{$IfDef DelphiZXingQRCode}
procedure TFPDFExt.QRCode(vX: double; vY: double; const QRCodeData: String;
DotSize: Double; AEncoding: TQRCodeEncoding);
procedure TFPDFExt.QRCode(vX, vY, vQRCodeSize: double; const QRCodeData: String;
AEncoding: TQRCodeEncoding);
var
qr: TDelphiZXingQRCode;
DotSize: double;
begin
qr := TDelphiZXingQRCode.Create;
try
qr.Encoding := AEncoding;
qr.QuietZone := 1;
qr.Data := widestring(QRCodeData);
DotSize := vQRCodeSize / qr.Rows;
finally
qr.Free;
end;

QRCode(vX, vY, QRCodeData, DotSize, AEncoding);
end;

function TFPDFExt.QRCode(vX: double; vY: double; const QRCodeData: String;
DotSize: Double; AEncoding: TQRCodeEncoding): double;
var
qr: TDelphiZXingQRCode;
PDF2DMatrix: TFPDF2DMatrix;
Expand All @@ -1553,6 +1574,8 @@ procedure TFPDFExt.QRCode(vX: double; vY: double; const QRCodeData: String;
PDF2DMatrix[r][c] := 0;
end;
end;

Result := qr.Rows * DotSize;
finally
qr.Free;
end;
Expand Down

0 comments on commit 28a5d68

Please sign in to comment.