简体   繁体   English

飞碟 - HTML到PDF和许可(iText)

[英]Flying Saucer - HTML to PDF and Licensing (iText)

I'm writing code to convert HTML to PDF, which includes the following 2 dependencies: 我正在编写代码将HTML转换为PDF,其中包括以下2个依赖项:

    <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 . 我能看到的唯一方法就是使用ITextRenderer Unfortunately, it looks like this is iText 5, which requires AGPL license, or paying a large licensing fee. 不幸的是,看起来这是iText 5,它需要AGPL许可证,或支付大量许可费。

Seems pretty clear to me, based on this license: https://github.com/flyingsaucerproject/flyingsaucer/blob/master/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)? 有没有其他方法可以做到这一点,不需要iText(或许可软件)?

I've tried Apache PDFBox, but it's so low-level, I'm not sure it would be possible. 我已经尝试过Apache PDFBox,但它的级别太低了,我不确定它是否可行。 I know it wouldn't be easy. 我知道这并不容易。 HTML -> PDF definitely isn't possible. HTML - > PDF肯定是不可能的。

OpenPDF looked kinda weak. OpenPDF看起来有点弱。

Any thoughts/suggestions? 有什么想法/建议?

This is a somewhat small part of our project (startup), so licensed software isn't the first choice. 这是我们项目(启动)的一小部分,因此许可软件不是首选。

Thanks. 谢谢。

As of today, there are three implementations of Flying Saucer available, one of which is OpenPDF. 截至今天,飞碟有三种实现方式,其中一种是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-core - 核心库和Java2D渲染
  • org.xhtmlrenderer:flying-saucer-pdf - PDF output using iText 2.x org.xhtmlrenderer:flying-saucer-pdf - 使用iText 2.x的PDF输出
  • org.xhtmlrenderer:flying-saucer-pdf-itext5 - PDF output using iText 5.x org.xhtmlrenderer:flying-saucer-pdf-itext5 - 使用iText 5.x输出PDF
  • org.xhtmlrenderer:flying-saucer-pdf-openpdf - PDF output using OpenPDF org.xhtmlrenderer:flying-saucer-pdf-openpdf - 使用OpenPDF输出PDF
  • org.xhtmlrenderer:flying-saucer-swt - SWT output org.xhtmlrenderer:flying-saucer-swt - SWT输出
  • org.xhtmlrenderer:flying-saucer-log4j - Logging plugin for log4j org.xhtmlrenderer:flying-saucer-log4j - log4j的日志插件

iText 2.x has unfixed security bugs. iText 2.x有不固定的安全漏洞。 New projects should avoid it. 新项目应该避免它。

OpenPDF and Flying Saucer itself are both licensed under LGPL. OpenPDF和Flying Saucer本身都是LGPL许可的。 So you can use flying-saucer-pdf-openpdf now to avoid security issues with iText 2 and licensing issues with iText 5. 因此,您现在可以使用flying-saucer-pdf-openpdf来避免iText 2的安全问题以及iText 5的许可问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM