Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flying Saucer - HTML to PDF and Licensing (iText)

I'm writing code to convert HTML to PDF, which includes the following 2 dependencies:

    <dependency>
        <groupId>org.xhtmlrenderer</groupId>
        <artifactId>flying-saucer-core</artifactId>
        <version>9.1.6</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.xhtmlrenderer</groupId>
        <artifactId>flying-saucer-pdf-itext5</artifactId>
        <version>9.1.6</version>
        <scope>compile</scope>
    </dependency>

I have it working. And the only way I can see to do this is using the ITextRenderer. Unfortunately, it looks like this is iText 5, which requires AGPL license, or paying a large licensing fee.

Seems pretty clear to me, based on this license: https://github.com/flyingsaucerproject/flyingsaucer/blob/master/LICENSE

Is this correct?

Is there any other way to do this that doesn't require iText (or licensed software)?

I've tried Apache PDFBox, but it's so low-level, I'm not sure it would be possible. I know it wouldn't be easy. HTML -> PDF definitely isn't possible.

OpenPDF looked kinda weak.

Any thoughts/suggestions?

This is a somewhat small part of our project (startup), so licensed software isn't the first choice.

Thanks.

like image 406
yngwietiger Avatar asked Jul 31 '18 13:07

yngwietiger


1 Answers

As of today, there are three implementations of Flying Saucer available, one of which is OpenPDF.

Quoting from their readme (emphasis mine):

The available artifacts are:

  • org.xhtmlrenderer:flying-saucer-core - Core library and Java2D rendering
  • org.xhtmlrenderer:flying-saucer-pdf - PDF output using iText 2.x
  • org.xhtmlrenderer:flying-saucer-pdf-itext5 - PDF output using iText 5.x
  • org.xhtmlrenderer:flying-saucer-pdf-openpdf - PDF output using OpenPDF
  • org.xhtmlrenderer:flying-saucer-swt - SWT output
  • org.xhtmlrenderer:flying-saucer-log4j - Logging plugin for log4j

iText 2.x has unfixed security bugs. New projects should avoid it.

OpenPDF and Flying Saucer itself are both licensed under LGPL. So you can use flying-saucer-pdf-openpdf now to avoid security issues with iText 2 and licensing issues with iText 5.

like image 158
Dario Seidl Avatar answered Nov 09 '22 18:11

Dario Seidl