asp.net core razor 使用内存流 生成文件

浪淘沙3周前后端20
 #region 获取简历html
 var url = $"{Request.Scheme}://{Request.Host}/hr/jl_view?stuid={stuid}&act=down";

         
 var clientHelper = new HttpClientHelper();
 var getHeaders = new Dictionary<string, string>
 {
    
 };
 string getResult = await clientHelper.GetAsync(url, getHeaders);

 new Aspose.Words.License().SetLicense("Aspose.Total.NET.lic");//注册码
 var doc = new Document();
 var builder = new DocumentBuilder(doc);

 // 加载 HTML 内容
 builder.InsertHtml(getResult);

 // 保存为 PDF
 //doc.Save("output.pdf", SaveFormat.Pdf);
 // 使用内存流输出 PDF
 using (var stream = new MemoryStream())
 {
     doc.Save(stream, Aspose.Words.SaveFormat.Pdf);

     stream.Position = 0; // 很重要:重置流位置

     return File(stream.ToArray(), "application/pdf", "output.pdf");
 }
 #endregion


相关文章

_LayoutAdmin.cshtml 取得url,调用ViewComponent 视图

_LayoutAdmin.cshtml 取得url,调用ViewComponent 视图

<body id="watermark-parent"> @{ var name = Furion.App.HttpC...

SqlSugar 无实体更新

 #region 保存反馈回复  /// <summary>  /// 保存反馈回复  /// <...

JNTemplate 模板标签传递url参数

一、模板 private readonly SqlSugar.ISqlSugarClient _db;  public Index1M...

asp.net core razor 写入读取cookie集合

@{     Layout = null; } <form method="post">...

asp.net core SqlSugar对SugarParameter 参数的调试

string sql = "select id,xm from stu where phone=@phone&...

wangeditor编辑器

<!--编辑器--> <link href="/wangeditor/style.css" rel="stylesheet&quo...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。