How to align two paragraphs to the left and right on the same line in PdfKit?

678 Views Asked by At

I am trying to achieve having two texts on the same line on the left and right sides. An image of the expected result is shown below

enter image description here

I tried to do the following but the result is not correct

doc.font('Bold').text("My long company name in english", { align: 'left', width: 195, continued: true }).text(" ", {width: 100, continued: true}).text("My long company name in arabic", {width: 195, align: "right"});

What I am trying to do is to have my company name on the left and right side and then the logo image in the middle. But when trying to do this, I am getting this result enter image description here

1

There are 1 best solutions below

0
Yosua Dc On
doc
        .font('Helvetica')
        .fontSize(16)
        .text(`LEFT`, {continued:true})
        .text(`RIGHT`, {
            align: 'right'
        }).moveDown()
    doc
        .font('Helvetica')
        .fontSize(16)
        .text(`LEFTs`, {continued:true, align: 'left'})
        .text(`middle`, {continued:true, align: 'center'})
        .text(`RIGHT`, {
            align: 'right'
        });
    doc.end()

you should use property continued true on first and second align (no need for the last item)

example result: