diff --git a/source/fpdf.pas b/source/fpdf.pas index a3dc61c..f7679a4 100644 --- a/source/fpdf.pas +++ b/source/fpdf.pas @@ -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 ; @@ -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 diff --git a/source/fpdf_ext.pas b/source/fpdf_ext.pas index 5d56adc..6f509b1 100644 --- a/source/fpdf_ext.pas +++ b/source/fpdf_ext.pas @@ -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); @@ -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; @@ -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;