[Html2PdfConverter] [Html2PdfConverter]  Text Jusstification

[Html2PdfConverter] [Html2PdfConverter]  Text Jusstification

  
Forge Component
(40)
Published on 24 Mar by Guilherme Pereira
40 votes
Published on 24 Mar by Guilherme Pereira
Hi there, 

I'm converting an html page to pdf using Html2PdfConverter. On the HTML the text paragraphs are properly justified (using css- text-align:justify;) but on the PDF they show up aligned to the left. Has any one experienced a similar problem and found a solution? 

thanks
Hi Tiago,

can you try to add the following html attribute tou your html element?

align="justify" 

I'm not sure it will work, but give it a try.
Let us know how it goes.

Cheers,
Miguel
Miguel "Kelter" Antunes wrote:
Hi Tiago,

can you try to add the following html attribute tou your html element?

align="justify" 

I'm not sure it will work, but give it a try.
Let us know how it goes.

Cheers,
Miguel
 Thanks for the reply Miguel, but i also tried the html attribute you mentioned with no success.
 
Hi Tiago,

Try to print the page in your browser. Do you get left aligned as well?

If so you probably have a print media query overriding that somewhere.

If not I'm unsure :)

Cheers,
Guilherme
Hi Guilherme, 

using the browser's print feature it appears properly justified, so so the problem should be related with the html2pdf converter. Thanks for the tip though. 


Hi Tiago,

That could be very well the case. A couple of other sugestions:
  • When the page is printed onto a pdf the Layout closely resembles a tablet. SO you can check if you have some other style based on the width of the viewport that could be causing this (perhaps resizing the browser window to check)
  • You can download wkhtmltopdf directly and play with it from the command line and see if any of the command line parameters can help you in solving the issue and if you find it use the same parameter when using the component.
Hope this helps

Guilherme
Solution
Problem solved :) it was related to a css class that was forcing the style "white-space: pre-wrap;", removing it made the text appear justified on the PDF. Thanks for help. 
Solution