How can I show the appearance of digital signature?

I follow the example on DigitalSignaturesTest - C# (Xamarin).
For the function of digital signature is successfully done.
But the appearance of the digital signature isn't working.
I use this code and getting error on widgetAnnot.RefreshAppearance(); :

certpass = passphrase.Text;
field_ = "Signature1";
filepathpath = file.FilePath;

PDFDoc pDFDoc = new PDFDoc(filepathpath);
                var signField = pDFDoc.FieldCreate(field_, Field.Type.e_signature);

                SignatureHandlerId sigHandlerId = pDFDoc.AddStdSignatureHandler(certpath, certpass);
                var sigField = pDFDoc.GetField(field_);

                Obj sigimg = sigField.UseSignatureHandler(sigHandlerId);

                //Widget widgetAnnot = new Widget(sigField.GetSDFObj());
                Widget widgetAnnot = new Widget(sigimg);

                System.Diagnostics.Debug.WriteLine(sigField.GetType());
                System.Diagnostics.Debug.WriteLine(sigField.GetType().ToString());
                Obj sigDict = sigField.UseSignatureHandler(sigHandlerId);

                //Add more information to the signature dictionary
                sigDict.PutName("SubFilter", "adbe.pkcs7.detached");
                sigDict.PutString("Name", "Kukuh");
                sigDict.PutString("Location", "Bogor");
                sigDict.PutString("Reason", "Tanda Tangan Elektronik");

                Console.WriteLine($"sigfield = {sigField}");
                Console.WriteLine($"sigdict = {sigDict}");
                Console.WriteLine($"field_ = {field_}");
                Console.WriteLine($"sighand = {sigHandlerId}");

                ElementWriter apWriter = new ElementWriter();
                ElementBuilder apBuilder = new ElementBuilder();
                apWriter.Begin(pDFDoc);

                pdftron.PDF.Image sigImg = pdftron.PDF.Image.Create(pDFDoc, imgpath);
                double w = sigImg.GetImageWidth(),
                       h = sigImg.GetImageHeight();
                pdftron.PDF.Element apElement = apBuilder.CreateImage(sigImg, 0, 0, w, h);
                apWriter.WritePlacedElement(apElement);
                Obj apObj = apWriter.End();
                apObj.PutRect("BBox", 0, 0, w, h);
                apObj.PutName("Subtype", "Form");
                apObj.PutName("Type", "XObject");
                apWriter.Begin(pDFDoc);
                apElement = apBuilder.CreateForm(apObj);
                apWriter.WritePlacedElement(apElement);
                apObj = apWriter.End();
                apObj.PutRect("BBox", 0, 0, w, h);
                apObj.PutName("Subtype", "Form");
                apObj.PutName("Type", "XObject");

                widgetAnnot.SetAppearance(apObj);
                widgetAnnot.RefreshAppearance();

                string[] fileName_ = filepathpath.Split('.');
                pDFDoc.Save(fileName_[0] + "_signed.pdf", 0);

Calling RefreshAppearance after calling SetAppearance will typically wipe out your custom appearance. RefreshAppearance generates a “default” appearance.

However, Signatures do not have a default appearance, so for this type of Widget it does nothing.

You did not mention what the “error” is, but it certainly looks incorrect that you create a second form Xobject.

This forum post shows how to create a custom appearance.

If that doesn’t help, please post a screenshot of the “error”.