using ExtractResFile.AsposeHook; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; using System.ComponentModel.DataAnnotations; using System.Text; using System.Web; namespace LearnWordManage.Controllers { [ApiController] [Route("[controller]")] public class PdfController : ControllerBase { private readonly ILogger _logger; public PdfController(ILogger logger) { _logger = logger; HookManager.StartHook(); } /// /// html转换word数据模型 /// public class HtmlToPagePDFDto { [Required] public string? HtmlBody { get; set; } public string HeaderName { get; set; } = ""; } ///// ///// html转换word ///// //[HttpPost, Route("htmltopageword")] //public FileContentResult HtmlToPageWord(HtmlToPagePDFDto req) //{ // if (req.HtmlBody is null) // throw new Exception("无效转换内容"); // HttpContext.Response.Headers.AccessControlExposeHeaders = "Content-Disposition"; // HttpContext.Response.Headers.Add("Content-Disposition", " attachment;filename=" + HttpUtility.UrlEncode(req.HeaderName, Encoding.UTF8).ToUpper() + ".docx"); // var byteResult = AsposeWordManage.HtmlToPageWord(req.HtmlBody, req.HeaderName); // var fileName = req.HeaderName+".docx"; // var mimeType = "application/ms-word"; // return new FileContentResult(byteResult, mimeType) // { // FileDownloadName = fileName // }; //} } }