Android Question B4XSignatureTemplate: How can I add to text fields to bitmap?

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
I would like to know how can I add the content of edit fields to the signature bitmap.

The target would be can add the name and the DNI of the person that is signaturing to the resulting bitmap.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
Look at the source.
The time is outputted on the Signature if i remember correctly.

Copy it and make your own template out of it.

In my apps some Infos do appear on the image too. Even when signing...
 
Upvote 0

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
Look at the source.
The time is outputted on the Signature if i remember correctly.

Copy it and make your own template out of it.

In my apps some Infos do appear on the image too. Even when signing...

I have not been able to find the source code where the signature is assigned the date and time once captured.

I have only found the possibility to activate or deactivate this possibility

B4X:
SignatureTemplate.AddDateAndTime = true / False


I have managed to do it, but I think using too much code.

B4X:
Sub btnSignature_Click
    Dialog.ButtonsFont = XUI.CreateFontAwesome(20)
    Dim rs As ResumableSub = Dialog.ShowTemplate(SignatureTemplate, Chr(0xF00C), "", Chr(0xF00D))
    Dialog.GetButton(XUI.DialogResponse_Positive).TextColor = XUI.Color_Green
    Dialog.GetButton(XUI.DialogResponse_Cancel).TextColor = XUI.Color_Red
    Dialog.ButtonsFont = XUI.CreateDefaultBoldFont(15) 'return it to the default font. It will no longer affect the current dialog
    Wait For (rs) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        ImageView1.SetBitmap(SignatureTemplate.Bitmap.Resize(ImageView1.Width, ImageView1.Height, True))
            Private cvs As B4XCanvas
            cvs.Initialize(Pane1)
            Private cvsRect As B4XRect
            cvsRect.Initialize(0dip, 0dip, Pane1.Width, Pane1.Height)
            cvs.DrawBitmap(SignatureTemplate.Bitmap.Resize(ImageView1.Width, ImageView1.Height, True), cvsRect)
            Private f As B4XFont
            f = XUI.CreateDefaultFont(10)
            cvs.DrawText("Hola", 10, 10, f, XUI.Color_Cyan, "LEFT")
            cvs.DrawText("Caracola", 10, 22, f, XUI.Color_Red, "LEFT")
        Dim out As OutputStream = File.OpenOutput(File.DirApp, "signature.png", False) 'don't use File.DirApp in real applications
        SignatureTemplate.Bitmap.WriteToStream(out, 100, "PNG")
        out.Close
    End If
End Sub

Could you tell me if there is a more correct way to do it?

Could the text be made to already appear in the signature dialog itself so that the user could see it before signing?
 
Upvote 0
Top