user8095847
user8095847

Reputation:

JavaFx html formatted text in pdf using iText with formatation

Is it possible to set a formatted HTML-Text (Color, Alignment, ...) from a HTMLEditor to an "editable" PDF using iText.

I didn't find anything on the internet.

Thanks.

Upvotes: 0

Views: 431

Answers (2)

Joris Schellekens
Joris Schellekens

Reputation: 9057

The easiest way of doing this is (as Amedee suggested) using pdfHTML. It's an iText7 add-on that converts HTML5 (+CSS3) into pdf syntax.

The code is pretty straightforward:

    HtmlConverter.convertToPdf(
        "<b>This text should be written in bold.</b>", // html to be converted
        new PdfWriter(
            new File("C://users/user2002/output.pdf")  // destination file
        )
    );

To learn more, go to https://itextpdf.com/itext7/pdfHTML

Upvotes: 3

user8095847
user8095847

Reputation:

I found a Solution in this post using The Flying Saucer: this

Upvotes: 0

Related Questions