Create an QRCode for an PDF at runtime

In my XData-Server I want to generate a pdf that includes a QRCode.

how can create and receive a qrcode image from a on runtime created TTMSFNCWXQRCode object

for example
qr := TTMSFNCWXQRCode.Create(self);
qr.Visible := False;
qr.ErrorCorrectionLevel := eclH;
qr.Text := '12345';
qr.CreateQRCode(qr.text);

// How can i get the qrCode as Picture here
// qrbmp := qr.OnGetQRCode?

pdf := TTMSFNCPDFLib.Create;
try
  pdf.BeginDocument('sample.pdf');
  pdf.PageSize := psA4;
  pdf.Header := '';
  pdf.Footer := '';
  pdf.NewPage;
  pdf.Graphics.Font.Name :='Roboto';
  //pdf.Graphics.Font.Color := ;
  pdf.Graphics.Font.Style := [];
  pdf.Graphics.Font.SizeNoScale := 22;
  pdf.Graphics.DrawText('ANAMNESE', PointF(20,20));
  pdf.Graphics.DrawImage( ---- The QRCode-Bitmap ----, RectF(10,10,50,50));
  pdf.EndDocument(true);
finally
  pdf.Free;
end;

Hi,

For the WX components to work the Parent needs to be assigned.
Other than that, the QR code generation is asynchronous due to the underlying library that is used. Unfortunately there is no way around this so the best you can do is call CreateQRCode or set the Text property and then in the OnGetQRCode event generate the PDF.

procedure TForm4.TMSFNCWXQRCode1GetQRCode(Sender: TObject;
  ABitmap: TTMSFNCBitmap);
begin
  //ABitmap gives access to the TTMSFNCBitmap to use with DrawImage
end;