Hi webwizgordon,
Thank you for contacting Syncfusion support.
We can save the PDF document with Handwritten signature and form field data in the server side by using SaveDocument method and we can access the web action method in the client side by using the ServerActionSettings API.
Please refer to the below sample and code snippet.
Code Snippet for client side:
<button onclick="save()">SaveDocument</button>
function save() {
var pdfViewer = document.getElementById('pdfviewer1').ej2_instances[0];
pdfViewer.serverActionSettings.download = "SaveDocument";
pdfViewer.download();
pdfViewer.serverActionSettings.download = "Download";
} |
Code Snippet for server side:
[AcceptVerbs("Post")]
[HttpPost]
[Route("api/[controller]/SaveDocument")]
public ActionResult SaveDocument([FromBody] Dictionary<string, string> jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer(_cache);
string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
string base64String = documentBase.Split(new string[] { "data:application/pdf;base64," }, StringSplitOptions.None)[1];
if (base64String != null || base64String != string.Empty)
{
byte[] byteArray = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(byteArray);
var path = _hostingEnvironment.ContentRootPath;
System.IO.File.WriteAllBytes(path + "/ouptut.pdf", byteArray);
}
return Content(string.Empty);
}
|
Note: In the provided sample, we have a button (SaveDocument). On button-click, the newly created method (SaveDocument) in the PDFViewerController.cs file is invoked, and then the document is saved to the project location.
Kindly try this and let us know if you have any concerns about this.
Regards,
Vasugi.