Home > Enterprise >  Itext7 java how to Override trimFirst() on IElement
Itext7 java how to Override trimFirst() on IElement

Time:08-25

I would like to Override the trimfirst () method of an IElement returned by HtmlConverter (it appears that whitespace is eliminated by the HtmlConverter class).

Assuming you have a string like this:

Hello                  my name is Roger !

after running these lines of code :

List<IElement> lst = HtmlConverter.convertToElements(stringBuilder.toString(),cvProp);
           
for (IElement tagParag : lst) {
    p = (Paragraph) tagParag;
}

The result of text is this :

Hello my name is Roger!

This is the string before passing by the converter :

<p style='font-family:times-roman;font-size:10.5pt'>dalla notifica del presente atto di ingiunzione l'importo dovuto per complessivi Euro                             come qui di seguito specificati:</p>

What happened to the white spaces? There should have been some trim.

In another case I had used this solution result

  • Related