admin管理员组文章数量:1296485
I'm currently working on a PDF generation with pdfmake
in client-side, and I've a question :
I would like to adjust the size of my entire Column 2
+ A
, B
blocks, but I can't, even when I put huge values... The goal is to put Column 2
on top, and A
and B
just under it.
Is there something I'm doing bad ?
Here is my code (you can try in on : .html )
var dd = {
content: [
{
columns: [
{
text: 'Column 1',
style: [{bold: true, alignment: 'center'}],
width: 45
},
[
{
text: 'Column 2',
style: [{bold: true, alignment: 'center'}],
width: 200 // Nothing changes..
},
{
columns: [
{
text: 'A',
width: '*',
style: [{bold: true, alignment: 'center'}],
},
{
text: 'B',
width: '*',
style: [{bold: true, alignment: 'center'}],
}
]
}
],
{
text: 'Column 3',
width: '*',
style: [{bold: true, alignment: 'center'}],
}
]
}
]
}
I'm currently working on a PDF generation with pdfmake
in client-side, and I've a question :
I would like to adjust the size of my entire Column 2
+ A
, B
blocks, but I can't, even when I put huge values... The goal is to put Column 2
on top, and A
and B
just under it.
Is there something I'm doing bad ?
Here is my code (you can try in on : http://pdfmake/playground.html )
var dd = {
content: [
{
columns: [
{
text: 'Column 1',
style: [{bold: true, alignment: 'center'}],
width: 45
},
[
{
text: 'Column 2',
style: [{bold: true, alignment: 'center'}],
width: 200 // Nothing changes..
},
{
columns: [
{
text: 'A',
width: '*',
style: [{bold: true, alignment: 'center'}],
},
{
text: 'B',
width: '*',
style: [{bold: true, alignment: 'center'}],
}
]
}
],
{
text: 'Column 3',
width: '*',
style: [{bold: true, alignment: 'center'}],
}
]
}
]
}
Share
Improve this question
edited Dec 2, 2019 at 8:28
cocool97
asked Dec 1, 2019 at 21:04
cocool97cocool97
1,2511 gold badge11 silver badges23 bronze badges
3 Answers
Reset to default 3you need to use table attribute into content instead of columns. please look into pdfmake/playground.html properly you will surely get an answer. I have uploaded some content from that which is useful to you.
{
style: 'tableExample',
color: '#444',
table: {
widths: [200, 'auto', 'auto'],
headerRows: 2,
// keepWithHeaderRows: 1,
body: [
[{text: 'Header with Colspan = 2', style: 'tableHeader', colSpan: 2, alignment: 'center'}, {}, {text: 'Header 3', style: 'tableHeader', alignment: 'center'}],
[{text: 'Header 1', style: 'tableHeader', alignment: 'center'}, {text: 'Header 2', style: 'tableHeader', alignment: 'center'}, {text: 'Header 3', style: 'tableHeader', alignment: 'center'}],
['Sample value 1', 'Sample value 2', 'Sample value 3'],
[{rowSpan: 3, text: 'rowSpan set to 3\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor'}, 'Sample value 2', 'Sample value 3'],
['', 'Sample value 2', 'Sample value 3'],
['Sample value 1', 'Sample value 2', 'Sample value 3'],
['Sample value 1', {colSpan: 2, rowSpan: 2, text: 'Both:\nrowSpan and colSpan\ncan be defined at the same time'}, ''],
['Sample value 1', '', ''],
]
}
},
{
style: 'tableExample',
table: {
widths: [100, '*', 200, '*'],
body: [
['width=100', 'star-sized', 'width=200', 'star-sized'],
['fixed-width cells have exactly the specified width', {text: 'nothing interesting here', italics: true, color: 'gray'}, {text: 'nothing interesting here', italics: true, color: 'gray'}, {text: 'nothing interesting here', italics: true, color: 'gray'}]
]
}
},
refer http://pdfmake/playground.html this
Don't use array as a columns
child directly, put into objects stack
field, then you can specify width
:
columns: [
{
width: 45,
text: "Column 1",
},
{
width: 200,
stack: [
{ text: "Column 2" },
// ...
]
},
{
width: '*',
text: "Column 3",
}
]
本文标签: javascriptHow to adjust size of column with pdfmakeStack Overflow
版权声明:本文标题:javascript - How to adjust size of column with pdfmake? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741637602a2389731.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论