pdfmake
pdfmake copied to clipboard
Add Padding and rounded Border to the text
I want to add the text that looks like this:

I have tried this thing:
content: [
{text: "Lorem ipsum dolor sit amet", background: "#e5f6ff"}
]
But I want to add padding and add the rounded border to the text. How can I achieve this?
The only thing I found that works for creating padding on the outside is mainly the \t\t\t:
content: [
{
text: '\t\t\t\t\t\t\t\t\t\t\t\tText\t\t\t\t\t\t\t\t\t\t\t\t',
style: ['header', 'background1'],
},
],
styles: {
background1: {
background: '#5190a5'
},
header: {
fontSize: 22,
alignment: 'center',
color: 'white',
},
}
+1
Quick and dirty ... can also use a width test to measure content instead of passing width parameter
function makeTag(text = '', width = 30) {
let canvas = {
type: 'rect',
x: 0,
y: 0,
w:width,
h: 14,
r: 7,
color: '#990876',
lineColor: '#B08BCD',
}
let column = {
text,
width,
color: '#FFFFFF',
alignment:'center',
noWrap: true,
maxHeight: 16,
bold:true
}
return {
stack: [
{ canvas:[canvas] },
{ columns:[column],
relativePosition: { y: -11 },
style:{ fontSize:7, bold:true }
}
]
}
}
var dd = {
content: [
makeTag('Some tag', 40),
makeTag('Some other', 50),
]
}