asp.net-mvc – 使用SaveAs对话框下载Rotativa
发布时间:2020-12-16 03:42:05 所属栏目:asp.Net 来源:网络整理
导读:我正在使用Rotativa工具来显示pdf.它可以正常使用以下代码: public ActionResult PreviewDocument(){ var htmlContent = Session["html"].ToString(); var model = new PdfInfo { Content = htmlContent,Name = "PDF Doc" }; return new ViewAsPdf(model);}
我正在使用Rotativa工具来显示pdf.它可以正常使用以下代码:
public ActionResult PreviewDocument() { var htmlContent = Session["html"].ToString(); var model = new PdfInfo { Content = htmlContent,Name = "PDF Doc" }; return new ViewAsPdf(model); } 我想知道通过浏览器的“另存为”对话框下载pdf的方式,点击按钮而不是显示在某个iframe中. “new ViewAsPdf(model)”只返回pdf数据. 提前致谢. 解决方法
您可以向Rotativa调用添加其他属性,如下所示:
return new PartialViewAsPdf("PreviewDocument",pdfModel) { PageSize = Size.A4,FileName = "PDF Doc.pdf" }; 它会为你创建文件. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 在ASP.NET MVC中复制Webforms GridView
- asp.net – 带有内联样式表和媒体查询的Razor视图
- asp.net-mvc – 在ASP.NET MVC DisplayFor Html Helper中为
- asp.net – 谷歌浏览器在浏览器关闭后保留会话变量
- 引领从经典ASP到ASP.NET的跳跃,有什么建议吗?
- asp.net-core-mvc – 使用RenderBody()的UTF-8中的特殊字符
- asp.net – 如何结合ASP MVC 5和Emberjs
- asp.net-mvc – 在MVC中使用Code Behind Model
- asp.net – 普通Web API或Web API和OData?
- asp.net-core – ASP.NET Core Web Application控制台立即关
推荐文章
站长推荐
- asp.net-mvc-3 – 在MVC3中使用强类型视图时可能
- prolog – 如何理解ASP中的否定失败?
- asp.net-mvc – 存储库模式 – 如何正确处理JOIN
- asp.net – ‘NETCore.App’,版本’1.0.0-rc2-30
- 在ASP.NET MVC 3中以特定格式验证日期
- 如何在IIS 7上的经典ASP中启用大型文件的上传?
- .NET中的FileUpload控件的使用-原生JS(二)
- asp.net – 在RedirectToAction调用中传播QueryS
- asp.net-core – ASP.Net核心RC1:System.Argume
- asp.net-mvc-3 – 具有角色的AuthorizeAttribute
热点阅读