public ActionResult Complete(string id) { // Get an instance of the PadesSignatureFinisher class, responsible for completing the signature process var signatureFinisher = new PadesSignatureFinisher(Util.GetRestPkiClient()) { // Set the token for this signature (rendered in a hidden input field, see the view) Token = id }; // Call the Finish() method, which finalizes the signature process and returns the signed PDF var signedPdf = signatureFinisher.Finish(); // Get information about the certificate used by the user to sign the file. This method must only be called after // calling the Finish() method. var signerCert = signatureFinisher.GetCertificateInfo(); // At this point, you'd typically store the signed PDF on your database. For demonstration purposes, we'll // store the PDF on the App_Data folder and render a page with a link to download the signed PDF and with the // signer's certificate details. var appDataPath = Server.MapPath("~/App_Data"); if (!Directory.Exists(appDataPath)) { Directory.CreateDirectory(appDataPath); } var signedFileId = Guid.NewGuid(); var filename = signedFileId + ".pdf"; System.IO.File.WriteAllBytes(Path.Combine(appDataPath, filename), signedPdf); var signedFile = filename.Replace(".", "_"); // Note: we're passing the filename argument with "." as "_" because of limitations of ASP.NET MVC return(Json(signedFile)); }
public ActionResult Complete(BatchSignatureCompleteRequest request) { // Get an instance of the PadesSignatureFinisher class, responsible for completing the signature process var signatureFinisher = new PadesSignatureFinisher(Util.GetRestPkiClient()) { // Set the token for this signature (rendered in a hidden input field, see the view) Token = request.Token, // Set the result of the RSA signature. Notice that this call is not necessary on the "regular" batch signature example Signature = request.Signature }; // Call the Finish() method, which finalizes the signature process and returns the signed PDF var signedPdf = signatureFinisher.Finish(); // Get information about the certificate used by the user to sign the file. This method must only be called after // calling the Finish() method. var signerCert = signatureFinisher.GetCertificateInfo(); // At this point, you'd typically store the signed PDF on your database. For demonstration purposes, we'll // store the PDF on the App_Data folder and render a page with a link to download the signed PDF and with the // signer's certificate details. var appDataPath = Server.MapPath("~/App_Data"); if (!Directory.Exists(appDataPath)) { Directory.CreateDirectory(appDataPath); } var signedFileId = Guid.NewGuid(); var filename = signedFileId + ".pdf"; System.IO.File.WriteAllBytes(Path.Combine(appDataPath, filename), signedPdf); var signedFile = filename.Replace(".", "_"); // Note: we're passing the filename argument with "." as "_" because of limitations of ASP.NET MVC return Json(signedFile); }