我需要在显示它之前设置 .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/