gpt4 book ai didi

javascript - 如何使用pdfmake调整列的大小?

转载 作者:行者123 更新时间:2023-12-02 19:46:34 24 4
gpt4 key购买 nike

我目前正在客户端使用 pdfmake 生成 PDF,我有一个问题:

我想调整整个 Column 2 + AB block 的大小,但我不能,即使我放置了巨大的值...目标是将Column 2 放在顶部,将AB 放在其下面。
我是不是有什么做得不好的地方?
这是我的代码(您可以尝试:http://pdfmake.org/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'}],
}
]
}
]
}

最佳答案

you 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', '', ''],
]
}
},

关于javascript - 如何使用pdfmake调整列的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59129960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com