我正在使用pdfmake在 Angular JS 中生成 pdf。
我正在尝试根据动态文本减少/设置在 pdf 中显示的水印的相同字体大小。
我已经尝试过以下配置,playground
var dd = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
],
watermark:{
text:"Niklesh Raut",
header: {
fontSize: 22,
bold: true
},
anotherStyle: {
italic: true,
alignment: 'right'
}
}
}
也尝试过如下。
var dd = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
],
watermark:{
text:"Niklesh Raut",
styles: {
fontSize: 22,
bold: true
}
}
}
但运气不佳。
问题:如何设置/减小水印字体大小?
最佳答案
您好,发现以下样本来自 https://itnext.io/angularjs-exporting-to-pdf-using-pdfmake-js-library-49f3afec97ef
var docDefinition = {
header: function() {
return [
{
style: 'table',
margin: [62,35,62,35],
table: {
widths: ['*', '*'],
headerRows: 0,
body: [
[
{text: 'Booking Summary', style: 'topHeader', alignment: 'left'},
{
'base64-image-string-goes-here',
width: 150,
alignment: 'right'
}
]
]
},
layout: 'noBorders'
}
]
},
footer: function(currentPage, pageCount) {
return [
{text: currentPage.toString() + ' of ' + pageCount, alignment: 'center', style: 'footer'}
]
},
content: [],
pageSize: 'A4',
pageMargins: [62,80,62,80],
styles: {
topHeader: {
fontSize: 20,
bold: true,
margin: [0, 6, 0, 30],
alignment: 'left'
},
table: {
fontSize: 8,
alignment: 'left',
color: 'black',
margin: [0, 5, 0, 15]
},
header: {
fontSize: 16,
bold: true,
margin: [0, 10, 0, 15],
alignment: 'left'
},
footer: {
fontSize: 8,
margin: [0, 25, 0, 17],
alignment: 'center'
}
}
};
pdfMake.createPdf(docDefinition).download();
};
关于javascript - 如何在 "pdfmake"javascript库中设置水印的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52118272/