public async Task <ActionResult> ConvertHtmlToPdf() { var postData = AppTools.GetRequestBodyEntity <ExportModel>(HttpContext); string htmlContent = postData.Content; string title = postData.Title; try { return(await Task.Run(() => { var doc = new HtmlToPdfDocument() { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4Plus, }, Objects = { new ObjectSettings() { PagesCount = true, HtmlContent = htmlContent, WebSettings ={ DefaultEncoding = "gb2132" }, } } }; byte[] pdf = PdfConverter.Convert(doc); var f = File(pdf, "application/pdf", title, true); return f; })); } catch (Exception) { return(null); } }