I'm trying to paint the signature image from a TTMSFNCSignatureCapture control on a PDF document:
Var
PDFLib: TTMSFNCPDFLib;
rect : TRectF;
bmp : TTMSFNCBitmap;
begin
PDFLib:= TTMSFNCPDFLib.Create();
PDFLib.BeginDocument('document.pdf');
PDFLib.NewPage();
PDFLib.Title:= 'My page title';
PDFLib.Footer:= 'My page footer';
PDFLib.Graphics.Font.Name := 'Arial';
PDFLib.Graphics.Font.Size := 10;
PDFLib.Graphics.Fill.Color := gcNull;
bmp:= TTMSFNCBitmap.Create();
bmp.LoadFromURL(SignatureCapture.GetBase64Img);
rect.Left:= 100;
rect.Top:= 600;
rect.Right:= 100 + bmp.Width;
rect.Bottom:= 600 + bmp.Height;
PDFLib.Graphics.DrawImage(bmp , rect);
PDFLib.EndDocument(true);
end;
Result:
The code completion also offered me:
bmp:= TTMSFNCBitmap.CreateFromURL(string);
but the compiler is saying
Incompatible types: got "TGraphic" expected "TTMSFNCBitmap"
I also tried to set the header and footer text, what isn't working in my case.
Furthermore the using of TRectF is really clumsy, almost none of the methods are accepted by the compiler.
For example:
rect.SetLocation();
rect.Offset();
rect.Inflate()
etc.
What is the reason, when using TRectF under WEBCore, all the methods and properties are not available, disabled by compiler switch?
unit VCL.TMSFNCTypes;
TRectF = record
{$IFNDEF WEBLIB}
private
function GetWidth: Single;
procedure SetWidth(const Value: Single);
function GetHeight: Single;
procedure SetHeight(const Value: Single);
function GetSize: TSizeF;
procedure SetSize(const Value: TSizeF);
public
procedure Offset(const DX, DY: Single);
procedure Inflate(const DX, DY: Single);
function CenterAt(const ADesignatedArea: TRectF): TRectF;
function SnapToPixel(const AScale: Single; const APlaceBetweenPixels: Boolean): TRectF;
function FitInto(const ADesignatedArea: TRectF; out Ratio: Single): TRectF; overload;
function FitInto(const ADesignatedArea: TRectF): TRectF; overload;
function IsEmpty: Boolean;
function IntersectsWith(const R: TRectF): Boolean;
function CenterPoint: TPointF;
function Empty: TRectF;
property Width: Single read GetWidth write SetWidth;
property Height: Single read GetHeight write SetHeight;
property Size: TSizeF read GetSize write SetSize;
case Integer of
0: (Left, Top, Right, Bottom: Single);
1: (TopLeft, BottomRight: TPointF);
{$ENDIF}
{$IFDEF WEBLIB}
Left, Top, Right, Bottom: Single;
{$ENDIF}
end;
{$ENDIF}
Pieter
(Pieter)
November 30, 2020, 7:25pm
4
Because there are some shortcomings in supporting record helpers. As soon as those are tackled, we can enable full record helper support.
Pieter
(Pieter)
November 30, 2020, 8:42pm
5
We noticed an issue in generating the image, we'll investigate this here as soon as possible.
Ok, thank you. What about the Header and Footer string?
Pieter
(Pieter)
December 1, 2020, 7:58am
7
Set It before calling NewPage
Pieter
(Pieter)
December 4, 2020, 10:00am
8
Hi,
We have also applied a fix for saving the signature. The next version of TMS FNC UI Pack will address this
Hello,
what do you mean with "saving" the signature? Saving the signature as base64 string seems working, but I would like to draw the signature onto a pdf canvas.
Pieter
(Pieter)
December 4, 2020, 10:20am
10
Yes, that's what we fixed. We fixed the black screen issue when exporting.
Is it realistic to have this fix this week?
delphi 10.3 / TMS WEB Core 1.6 beta / TMS FNC Core 3.2.2.1
Is this fix in the current TMS FNC Core 3.2.2.1 ? I still get a black rectangle when trying to paint the Base64 image from a TWebSignatureContol onto a PDF canvas.
This is the code:
g:= TGraphic.Create();
g.OnChange:= TNotifyEvent(procedure (Sender: TObject)
begin
rect.Left:= 40;
rect.Top:= 600;
rect.Right:= 40 + g.Width;
rect.Bottom:= 600 + g.Height;
PDFLib.Graphics.DrawImage(g , rect);
PDFLib.EndDocument().SaveToFile(FileName);
TTMSFNCUtils.OpenFile(FileName);
end);
g.LoadFromResource(SignatureCapture.GetAsBase64Image);
Its working when I load any other image file by stream:
stream:= TElectronBinaryDataStream.Create();
stream.LoadFromFile('AnyOtherImage.jpg');
.
.
.
g.LoadFromResource(stream.Base64);
When I'm saving an image from the SignatureControl to file, its looking ok - at least I can open it by the Windows Foto viewer:
When relaoding it, it produces the black rectange when painting on the PDF canvas.
Pieter
(Pieter)
December 13, 2020, 1:34pm
14
I'll check and report back as soon as possible.
Pieter
(Pieter)
December 14, 2020, 11:04am
15
The fix was made in TTMSFNCSignatureCapture component, in the update of TMS FNC UI Pack 3.2.2.1.
For the moment I would like to use the TWebSignatureContol control, can you fix it for the final TMS WEB Core 1.6 version?
Pieter
(Pieter)
December 14, 2020, 12:06pm
17
We'll investigate this here and apply a fix for the TWebSignatureControl as soon as possible.
I can confirm, that with the TTMSFNCSignatureCapture control, everything works perfect.
Pieter
(Pieter)
December 14, 2020, 3:05pm
19
Hi,
We've now fixed the issue in TWebSignatureCapture as well. The final 1.6 release of TMS WEB Core will have this fix included.