I'm trying to implement progress bar inside PDF using pdfmake js library. Gone through working examples mentioned here vectors in pdfmake, but unable to find progress or partial filled canvas example.
I'm looking for workaround which depicts rectangular canvas with filled color based on dynamic value like below.
{
canvas: [
{
type: 'line',
x1: 40, y1: 100,
x2: 260, y2: 100,
lineWidth: 10,
lineCap: 'square',
lineColor: 'green',
// fillPercentage: 20
}
]
}
Found workaround.
solution_1: stacking 2 lines.
{
canvas: [
{
type: 'line',
x1: 10, y1: 100,
x2: 100, y2: 100,
lineWidth: 15,
lineColor: '#eef2d7',
lineCap: 'round'
},
{
type: 'line',
x1: 10, y1: 100,
x2: 50, y2: 100, // 50 percent completion
lineWidth: 15,
lineColor: 'green',
lineCap: 'round'
}
]
}
solution_2: stacking 2 rectangular.
{
canvas: [
{
type: 'rect',
x: 0,
y: 0,
w: 100,
h: 30,
opacity: 0.1,
color: 'white',
lineColor: 'black'
},
{
type: 'rect',
x: 0,
y: 0,
w: 70, // 70 percent completion
h: 30,
color: 'green',
lineColor: 'black'
},
]
}