11

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.

yngwietiger
  • 1,044
  • 1
  • 11
  • 15
  • 2
    I'm voting to close this question as off-topic because this is a licensing question, not a technical question. – Bruno Lowagie Jul 31 '18 at 13:55
  • Flying Saucer is a third party product that isn't endorsed by iText Group. iText has its own [HTML to PDF functionality](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml). It is correct that a commercial license is needed for closed source distribution of iText (AGPL). OpenPDF is a fork of the obselete iText 2 [and shouldn't be used in a commercial context](https://developers.itextpdf.com/question/versions-older-than-5) in spite of what its distributor claims. The license price of iText will be much less than the cost of development you'll need when using PDFBox. – Bruno Lowagie Jul 31 '18 at 14:00
  • What makes you say the license price for iText is large? Pricing of iText depends on your use of iText. A single server license costs about what you'd have to pay me if you'd hire me about 10 hours of work. Also: there are special conditions for startups who use iText in a SaaS context. We have given 100% reduction on the invoice of the first year. That means that you know the yearly price up-front, but you only have to start paying after 1 year (when we expect you already have some revenue). – Bruno Lowagie Jul 31 '18 at 14:02
  • 4
    You could try this https://github.com/danfickle/openhtmltopdf/ it is on top of PDFBox. – Tilman Hausherr Jul 31 '18 at 15:28
  • 1
    @TilmanHausherr Thanks. I'll take a look. BTW, it says that it's based on a fork of Flying Saucer. Does that mean it may have the same iText licensing issues? Or is it completely independent of iText? – yngwietiger Jul 31 '18 at 16:34
  • 1
    @yngwietiger I don't know. Look into the pom.xml or ask them. – Tilman Hausherr Jul 31 '18 at 17:20
  • 2
    @TilmanHausherr FYI, I was able to switch over to openhtmltopdf (from Flying Saucer) easily. Looks like it does everything I need it to do. BIG THANKS for the suggestion! (actually, I had looked at it briefly a few days ago, but had written it off for some reason). AIso, if you're curious, there are no references to iText (via "mvn dependency:tree | grep -i itext"), so it looks good there as well. Thanks again. – yngwietiger Aug 01 '18 at 17:59
  • 1
    Glad to hear that. I knew about that project because one of the guys (Emmeran Seehuber) helped improve PDFBox / fix bug(s). – Tilman Hausherr Aug 01 '18 at 18:57
  • I am using the same as above and in one of the PDF page I am getting my content overlapped – Juke Aug 12 '19 at 18:40

1 Answers1

16

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.

Community
  • 1
  • 1
Dario Seidl
  • 4,140
  • 1
  • 39
  • 55