I need to convert a String to fill an element of itext like a paragraph. I do not want to create a new document on the conversion, I just want it to receive a string and return something I could add as part of a pdf document. An example of the input I need to convert is:
<h1>Hello<h1></br>
<h3>This is a test to demonstrate a simple html code I just need to convert</h3>
You can parse your HTML string to elements and add these elements to a paragraph (by the way, I repaired your html string for the tests):
(from CreatePdf test
testHtmlToParagraph)After adding that
paragraphto an iTextDocumentyou get:With a slightly more interesting
css:you get