【问题标题】:iText7: Can you use Graphics2D?iText7:你能用 Graphics2D 吗?
【发布时间】:2018-03-29 23:29:34
【问题描述】:

在 iText5 中,可以像这样开始绘制 Graphics2D 对象

Rectangle rect = PageSize.A3.rotate();
PdfContentByte cb = writer.getDirectContent();
Graphics2D g = cb.createGraphics(rect.getWidth(), rect.getHeight());

“writer”是“PdfWriter”的一个实例。

iText7 中不存在 PdfContentByte,我还没有找到让 Graphics2D 参与其中的方法。这还有可能吗?

我完全知道现在有一个画布,您可以在上面绘制圆形、矩形、线条……但这意味着重新编写所有现有代码,所以如果您仍然可以以某种方式使用 Graphics2D,它将是首选方式。

【问题讨论】:

    标签: java graphics2d itext7


    【解决方案1】:

    您可以使用OrsonPDF 作为Graphics2D 翻译器,并将生成的PDF 嵌入到使用iText 创建的文档中。这里给出了一个完整的例子:

    https://jfree.github.io/orsonpdf/

    猜你喜欢
    • 2015-02-10
    • 2011-07-09
    • 2012-05-14
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-04
    相关资源
    最近更新 更多