51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
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<PdfController> _logger;
|
|
public PdfController(ILogger<PdfController> logger)
|
|
{
|
|
_logger = logger;
|
|
HookManager.StartHook();
|
|
}
|
|
|
|
/// <summary>
|
|
/// html转换word数据模型
|
|
/// </summary>
|
|
public class HtmlToPagePDFDto
|
|
{
|
|
[Required]
|
|
public string? HtmlBody { get; set; }
|
|
public string HeaderName { get; set; } = "";
|
|
}
|
|
|
|
///// <summary>
|
|
///// html转换word
|
|
///// </summary>
|
|
//[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
|
|
// };
|
|
//}
|
|
}
|
|
}
|