I am using pdfkit to generate pdf file and i want to send this pdf file to browser.
My following code is working fine and i am getting one pdf with text.
this worked for me:
artikelList.map(artikel => {
let yPos = doc.y;
doc
.fontSize(8)
.text(artikel.titel, (x = 50), (y = yPos))
.text(artikel.menge, (x = 200), (y = yPos))
.text(`${artikel.spOhne.toFixed(2)}€`, (x = 250), (y = yPos))
.text(`${(artikel.USt / 100).toFixed(2)}%`, (x = 350), (y = yPos))
.text(
`${(artikel.spOhne * (1 + artikel.USt / 100)).toFixed(2)}€`,
(x = 400),
(y = yPos)
)
.text(
`${(artikel.menge * artikel.spOhne * (1 + artikel.USt / 100)).toFixed(
2
)}€`,
(x = 475),
(y = yPos),
{ align: 'right' }
);
});
literally just fixing the y-position and then moving through the x-positions. I guess with adding rec
and stroke
it would be pretty straight forward to draw the lines around it.
Produces something that looks like this