如何在数据表中更改导出PDF字体大小? [英] How to change export PDF font size in datatables?
本文介绍了如何在数据表中更改导出PDF字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在打印页面时更改字体大小,但导出pdf文件时不能更改字体大小。
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ current current current current current current current current current current current current current current current current current current current current current current '
}
},
标题:true,
标题:'我的表标题',
orientation:'landscape'
},
{
extends:'print',
text:'Print',
customize:function(win){
$(win.document.body)
。 css('font-size','15pt')
$(win.document.body).find('table')
.addClass('compact')
.css('font-size','8pt');
},
标题:false,
标题:'',
orientation:'landscape'
},
/ pre>
你能帮助我吗?
解决方案在 html5.js 的src中/ a>,它创建一个默认对象文字
doc
保存默认设置:var doc = {
pageSize:config.pageSize,
pageOrientation:config.orientation,
content:[
{
table :{
headerRows:1,
body:rows
},
layout:'noBorders'
}
],
styles:{
tableHeader:{
bold:true,
fontSize:11,
color:'white',
fillColor:'#2d4154',
alignment:'center'
},
tableBodyEven:{},
tableBodyOdd:{
fillColor:'#f3f3f3'
},
tableFooter:{
bold:true,
fontSize:11,
color:'white',
fillColor:'#2d4154'
$,
标题:{
align:'center',
fontSize:15
},
message:{}
},
defaultStyle:{
fontSize:10
}
};
您可以使用
自定义
回调来更改这些默认设置:{
extends:'pdfHtml5',
文本:'保存PDF',
exportOptions:{
修饰符:{
页:'当前'
}
},
标题:真,
标题:'我的表标题',
orientation:'landscape',
customize:function(doc){
doc.defaultStyle.fontSize = 16; //< - 将字体大小设置为16而不是10
}
},
I have a datatable and i have print button and pdf button. I can change font size when print page but i can't change font size while exporting pdf file.
{ extend: 'pdfHtml5', text: 'Save PDF', exportOptions: { modifier: { page: 'current' } }, header: true, title: 'My Table Title', orientation: 'landscape' }, { extend: 'print', text: 'Print', customize: function ( win ) { $(win.document.body) .css( 'font-size', '15pt' ) $(win.document.body).find( 'table' ) .addClass( 'compact' ) .css( 'font-size', '8pt' ); }, header: false, title: '', orientation: 'landscape' },
can you help me?
解决方案If you look at the src of html5.js, it creates a default object literal
doc
holding default settings :var doc = { pageSize: config.pageSize, pageOrientation: config.orientation, content: [ { table: { headerRows: 1, body: rows }, layout: 'noBorders' } ], styles: { tableHeader: { bold: true, fontSize: 11, color: 'white', fillColor: '#2d4154', alignment: 'center' }, tableBodyEven: {}, tableBodyOdd: { fillColor: '#f3f3f3' }, tableFooter: { bold: true, fontSize: 11, color: 'white', fillColor: '#2d4154' }, title: { alignment: 'center', fontSize: 15 }, message: {} }, defaultStyle: { fontSize: 10 } };
You can use the
customize
callback to change those default settings :{ extend: 'pdfHtml5', text: 'Save PDF', exportOptions: { modifier: { page: 'current' } }, header: true, title: 'My Table Title', orientation: 'landscape', customize: function(doc) { doc.defaultStyle.fontSize = 16; //<-- set fontsize to 16 instead of 10 } },
这篇关于如何在数据表中更改导出PDF字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文