gpt4 book ai didi

pdfmake - 如何在pdfmake中设置文本的背景颜色和填充

转载 作者:行者123 更新时间:2023-12-04 10:03:53 25 4
gpt4 key购买 nike

我有一个字符串,我想将其设置为 pdf 的标题。我尝试使用以下代码。但是背景没有正常出现。我想将背景颜色设置为整行,但它恰好位于文本下方。任何帮助将不胜感激。

var dd = {

content: [
{
text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
style: 'header'
},
],
styles: {
header: {
fontSize: 18,
bold: true,
margin: [0, 0, 0, 10],
background:'blue',
color: 'white',
alignment:'center'
}
},
defaultStyle: {
// alignment: 'justify'
}

}

最佳答案

似乎没有办法设置文本的背景颜色和填充。我尝试了另一种解决方案,方法是创建表,表头只有一个无边框的单列,它适用于我的场景。

    var dd = {
content: [


{
style: 'header',
table: {
widths:'*',
body: [
[{
border: [false, false, false, false],
fillColor: '#5bc0de',
text: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.'
}]
]
}
},


]
}

关于pdfmake - 如何在pdfmake中设置文本的背景颜色和填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61686183/

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