Hi,
I am trying to implement same way as ASP.NET Core PDF Export Key Features Demo | Telerik UI for ASP.NET Core
but Its exporting in client side but it's not going to controller. Don't know what mistake I am doing. Is there a way to send the pad to controller and send it to email attachment. Below is my code.
$("#btnSubmit").on("click", function (e) {
e.stopPropagation();
e.preventDefault();
var sigval = signature.value();
$('#lblSearchError').text('');
if (sigval === undefined || sigval === '') {
$('#lblSearchError').text('*Signature field is required.');
} else {
var data = $("#submitForm").serializeArray();
var obj = { name: 'signature', value: sigval };
data.push(obj);
// Convert the DOM element to a drawing using kendo.drawing.drawDOM
kendo.drawing.drawDOM($("#mainContect"))
.then(function (group) {
// Render the result as a PDF file
return kendo.drawing.exportPDF(group, {
paperSize: "auto",
margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
});
})
.done(function (data) {
// Save the PDF file
kendo.saveAs({
type: 'POST',
dataURI: data,
fileName: "Provider.pdf",
proxyURL: '@Url.Action("Submit", "Provider")'
});
});
}
});
I tried proxyURL AND URL none of them worked. When I clicked on submit button it's just downloading the pdf file. But it not hitting controller.
and in controller
[HttpPost]
public ActionResult Submit(string contentType, string base64, string fileName)
{
//if (!ModelState.IsValid)
//{
// data.Id = 0;
// return Json(data, JsonRequestBehavior.AllowGet);
//}
//var providerData = portalServices.saveProviderData(data);
// return Json(providerData, JsonRequestBehavior.AllowGet);
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}