我正在使用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
}
}
}
但是没有运气。
问题:如何设置/减小水印的字体大小?
答案 0 :(得分:0)
您好,以下示例来自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();
};
答案 1 :(得分:0)
std::vector
水印适合页面,即使字符的长度为1,因此添加空格以使单词变成固定长度的单词,并使用以下代码
pdfmake
并将其用于水印
var stars = ' ';
var name = "Niklesh Raut";
var center = parseInt(stars.length/2) - parseInt(name.length/2);
var starsArr = stars.split("");
var nameArr = name.split("");
for(let i=0;i<name.length;i++){
starsArr[center+i] = nameArr[i];
}
console.log('|'+starsArr.join("")+'|');