c# - 设置 .pdf 名称但阻止使用 Rotativa 下载

标签 c# asp.net-mvc pdf rotativa

我需要在显示它之前设置 .pdf 名称。我试过这样设置

return new ViewAsPdf(GetViewName(), "", reportVM) 
{ 
   PageSize = Size.Letter, FileName = GetViewName() + "-" + DateTime.Now.ToShortDateString() + ".pdf"
 }; ,

但这样 .pdf 将自动下载。是否可以设置.pdf名称而不下载?

谢谢!

最佳答案

var pdfResult = new Rotativa.PartialViewAsPdf("YourPartialView", model) {
    SaveOnServerPath = path, // Save your place
    PageWidth = 200,
    PageHeight = 350,
};

// This section allows you to save without downloading 

pdfResult.BuildPdf(this.ControllerContext);
return RedirectToAction("Index", "Home");

关于c# - 设置 .pdf 名称但阻止使用 Rotativa 下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38829082/

相关文章:

c# - ASP.NET MVC 5 ApplicationUser 作为外键

java - 如何使用java代码和pdfbox从pdf文件中提取参数

c# - 调用 native 代码的多线程托管应用程序

javascript - 从 ASP.NET View 调用 C# 函数

c# - 在应该返回泛型类的方法中返回 int

c++ - 我可以使用什么开源 C++ 库在专有的闭​​源应用程序中显示 PDF 文件?

Django reportlab 插入分页符 html 端

c# - 如何在 iOS 上将文本字段居中?

c# - Unity 5.5.6f1 - native 插件不起作用,错误 DllNotFoundException

c# - 确定 .NET 类型的序列化大小和非托管内存效率