在ASP.NET CORE下生成PDF文档
原文链接:https://www.c-sharpcorner.com/article/creating-pdf-in-asp-net-core-mvc-using-rotativa-aspnetcore/
引入类库:Rotativa.AspNetCore
修改类Startup的方法Configure(IApplicationBuilder app, IHostingEnvironment env)
添加如下代码:
RotativaConfiguration.Setup(env);
调用ViewAsPdf 方法
public IActionResult Index()
{
return new ViewAsPdf("Index");
}
zai www文件夹中添加必要的文件:
view 内容
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<header>
<h1>Invoice</h1>
<address contenteditable>
<p>Jonathan Neal</p>
<p>101 E. Chapman Ave<br>Orange, CA 92866</p>
<p>(800) 555-1234</p>
</address>
</header>
<article>
<h1>Recipient</h1>
<address contenteditable>
<p>Demo Company<br>c/o Saineshwar</p>
</address>
<table class="meta">
<tr>
<th><span contenteditable>Invoice #</span></th>
<td><span contenteditable>000001</span></td>
</tr>
<tr>
<th><span contenteditable>Date</span></th>
<td><span contenteditable>January 1, 2018</span></td>
</tr>
<tr>
<th><span contenteditable>Amount Due</span></th>
<td><span id="prefix" contenteditable>र </span><span>600.00</span></td>
</tr>
</table>
<table class="inventory">
<thead>
<tr>
<th><span contenteditable>Item</span></th>
<th><span contenteditable>Description</span></th>
<th><span contenteditable>Rate</span></th>
<th><span contenteditable>Quantity</span></th>
<th><span contenteditable>Price</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="cut">-</a><span contenteditable>Front End Consultation</span></td>
<td><span contenteditable>Experience Review</span></td>
<td><span data-prefix>र </span><span contenteditable>150.00</span></td>
<td><span contenteditable>4</span></td>
<td><span data-prefix>र </span><span>600.00</span></td>
</tr>
</tbody>
</table>
<table class="balance">
<tr>
<th><span contenteditable>Total</span></th>
<td><span data-prefix>र </span><span>600.00</span></td>
</tr>
<tr>
<th><span contenteditable>Amount Paid</span></th>
<td><span data-prefix>र </span><span contenteditable>0.00</span></td>
</tr>
<tr>
<th><span contenteditable>Balance Due</span></th>
<td><span data-prefix>र </span><span>600.00</span></td>
</tr>
</table>
</article>
<aside>
<h1><span contenteditable>Additional Notes</span></h1>
<div contenteditable>
<p>A finance charge of 1.5% will be made on unpaid balances after 30 days.</p>
</div>
</aside>
</body>
</html>
最终效果图:
最新文章
- php 数据库备份、还原
- js 九九乘法表
- VS中展开和折叠代码
- 深入理解PHP内核(四)概览-PHP脚本的执行
- JavaWeb前端基础复习笔记系列 一
- HTTP抓包神器HTTP Analyzer V7 Build7.5.4汉化+注册机
- Path Sum,Path Sum II
- JavaScript中的execCommand()命令详解及实例展示
- Redis构建分布式锁
- [vijos 1642]班长的任务 [树形dp]
- TCP/IP 主机路由表获取
- 自学Zabbix3.5.7-监控项item-Applications
- Kubernetes 在生产环境中常用架构
- 配置MySQL的数据源
- LAMP环境快速搭建
- Linux环境下安装NodeJS和mongoDB
- android HttpClient将数据提交到服务器
- struts2常用标签详解(申明:来源于网络)
- 【BZOJ2724】【Violet 6】蒲公英
- jmeter报错之“请在微信客户端打开链接”
热门文章
- Java数据结构和算法(十):二叉树
- JQuery设置获取下拉菜单选项的值 多实例
- 行为类模式(四):迭代器(Iterator)
- Flink的keyby延时源码
- Capterra Software Categories
- [Windows Azure] Building worker role B (email sender) for the Windows Azure Email Service application - 5 of 5.
- python(51):Python vars() 函数
- iOS应用管理(优化)
- Flume中的HDFS Sink配置参数说明【转】
- Jackson 时间格式化,时间注解 @JsonFormat 用法、时差问题说明