I have a code here which actually converts HTML to PDF and sends it to an email but it is in ActionResult:
public ActionResult Index()
{
ViewBag.Title = "Home Page";
var coverHtml = RenderRazorViewToString("~/Views/Home/Test.cshtml", null);
var htmlContent = RenderRazorViewToString( "~/Views/Home/Test2.cshtml", null);
string path = HttpContext.Server.MapPath("~/Content/PDF/html-string.pdf");
PDFGenerator.CreatePdf(coverHtml, htmlContent, path);
//PDFGenerator.CreatePdfFromURL("https://www.google.com", path);
EmailHelper.SendMail("myemail@domain.com", "Test", "HAHA", path);
return View();
}
I want to turn this into a api format (api/SendPDF) using POST with the content ID and email address which it will be sent to, but I am not sure how to do it since I am very new to MVC and Web API. Appreciate some help on this.