0

I'm using html-pdf in Node.js to convert html text to a pdf. text-align: left, center, and right work. But text-align: justify does not work. When text-align is justified, it exports the text aligned left.

Here's the HTML code:

<p class="ql-align-justify"><span style="background-color: rgb(255, 255, 255);">Hello, this is some text. Hello, this is some text. Hello, this is some text. Hello, this is some text. Hello, this is some text. Hello, this is some text. Hello, this is some text. Hello, this is some text. </span></p>

Here's the CSS code:

      .ql-align-justify {
          text-align: justify;
      }

How do I make the text-align: justify work?

Page COW
  • 515
  • 13
  • 31
  • Can you post the html code as well please ? Anyway, have a look to this question, it may be helpful: https://stackoverflow.com/questions/28154353/text-align-justify-not-working-with-wkhtmltopdf – Tuko90 Jan 15 '20 at 12:57
  • I just added the HTML code. I saw that article and it did not work for me. – Page COW Jan 15 '20 at 13:02
  • I tried that solution and It works to me. I set a fixed width to the ql-align-justify. .ql-align-justify { text-align: justify; width: 500px; } – Tuko90 Jan 15 '20 at 13:14
  • I tried adding width. Width works. You can update the width and it will export the length you tell it; so if it's width: 100px, it will render 100px, width: 500px will render 500px. But the text is not justified. The text is still aligned left in the PDF. – Page COW Jan 15 '20 at 13:27

1 Answers1

0

It seems that you need to set WIDTH to your span, that will help.

Leo
  • 36
  • 4
  • ah, export to pdf, it hard. So try to do it with multiple spans or divs with marings or paddings - it is not very correct, but I think it can help – Leo Jan 15 '20 at 15:51