<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>export datatable to pdf</title>
<style type="text/css" media="screen">
table {
width: 400px;
}
table,
td,
th {
border: 1px solid #ddd;
}
.paginate_button {
border: 1px solid #ddd;
margin-right: 10px;
padding: 0 10px;
}
</style>
<script src="js/jquery.min.js"></script>
<script src='js/jquery.dataTables1.10.16.min.js' type="text/javascript"></script>
<script src='js/dataTables.buttons.js' type="text/javascript"></script>
<script src='js/pdfmake.js' type="text/javascript"></script>
<script src="js/vfs_fonts.js"></script>
<script src='js/buttons.html5.js' type="text/javascript"></script>
<script>
function down(data) {
var dd = {
content: [
data,
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
],
defaultStyle: {
font: '方正姚体'
}
};
pdfMake.fonts = {
Roboto: {
normal: 'Roboto-Regular.ttf',
bold: 'Roboto-Medium.ttf',
italics: 'Roboto-Italic.ttf',
bolditalics: 'Roboto-Italic.ttf'
},
方正姚体: {
normal: 'FZYTK.TTF',
bold: 'FZYTK.TTF',
italics: 'FZYTK.TTF',
bolditalics: 'FZYTK.TTF',
}
};
pdfMake.createPdf(dd).download();
}
$(function() {
$('.datatable').DataTable({
'dom': 'Btirlp',
"sPaginationType": "full_numbers",
'buttons': [{
"extend": 'pdfHtml5',
'title': '候选人详细说明', //导出文件名字
'text': '导出table数据pdf文件', //定义导出excel按钮的文字
"aButtons": "true",
// 'download': 'open',//直接在窗口打开
// 'orientation': 'landscape',
// 'pageSize': 'LEGAL',
'messageTop': '副标题位置信息'
}],
// "searching": true
"bDestroy": true,
// "bServerSide": true,
// "sAjaxSource": "",
"data": [{ id: 1, name: '小明1', desc: '年龄45,至今未婚,有房有车' }, { id: 2, name: '小明2', desc: '年龄45,至今未婚,有房有车' }, { id: 3, name: '小明3', desc: '年龄45,至今未婚,有房有车' }, { id: 4, name: '小明4', desc: '年龄45,至今未婚,有房有车' }, { id: 5, name: '小明5', desc: '年龄45,至今未婚,有房有车' }, { id: 6, name: '小明6', desc: '年龄45,至今未婚,有房有车' }, { id: 7, name: '小明7', desc: '年龄45,至今未婚,有房有车' }, { id: 8, name: '小明8', desc: '年龄45,至今未婚,有房有车' }, { id: 9, name: '小明9', desc: '年龄45,至今未婚,有房有车' }, { id: 10, name: '小明10', desc: '年龄45,至今未婚,有房有车' }, { id: 11, name: '小明1', desc: '年龄45,至今未婚,有房有车' }, ],
"aoColumns": [{
"sTitle": "id",
// "sWidth": "10%",
"mDataProp": "id"
}, {
"sTitle": "名称",
// "sWidth": "10%",
"mDataProp": "name"
}, {
"sTitle": "描述",
// "sWidth": "15%",
"mDataProp": "desc"
}],
"oLanguage": {
"sProcessing": "处理中...",
"sLengthMenu": "显示 _MENU_ 项结果",
"sZeroRecords": "没有匹配结果",
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix": "",
"sSearch": "搜索:",
"sUrl": "",
"sEmptyTable": "表中数据为空",
"sLoadingRecords": "载入中...",
"sInfoThousands": ",",
"oPaginate": {
"sFirst": "首页",
"sPrevious": "上页",
"sNext": "下页",
"sLast": "末页"
},
"oAria": {
"sSortAscending": ": 以升序排列此列",
"sSortDescending": ": 以降序排列此列"
}
},
"aoColumnDefs": []
});
})
</script>
</head>
<body>
<button onclick="down('pdf文件显示中文')">导出中文pdf文件</button>
<table class="datatable"></table>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
datatable、pdfmake、buttons.html5导出中文pdf文件
共8个文件
js:6个
html:1个
ds_store:1个
5星 · 超过95%的资源 需积分: 43 89 下载量 62 浏览量
2018-03-23
18:00:53
上传
评论 6
收藏 5.14MB ZIP 举报
温馨提示
datatable、pdfmake、buttons.html5导出中文pdf文件。资源包下载、解压后即可使用:打开test.html文件即可在浏览器点击 “导出table数据pdf文件” 即可导出table数据
资源推荐
资源详情
资源评论
收起资源包目录
datatable-pdf-export.zip (8个子文件)
datatable-pdf-export
test.html 5KB
js
pdfmake.js 2.37MB
jquery.min.js 82KB
jquery.dataTables1.10.16.min.js 80KB
vfs_fonts.js 9.16MB
dataTables.buttons.js 44KB
buttons.html5.js 42KB
.DS_Store 8KB
共 8 条
- 1
资源评论
- lollipop诗2018-05-28下载 学习一下
- shabble2019-06-14有帮助,挺有用
- nnpig2018-10-27真的不错,通过例子学到知识了
- homebest2022-06-17确实好用pdf不乱码了
yy_姐
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功