【问题标题】:display clob with all text formatting in itext在 itext 中显示具有所有文本格式的 clob
【发布时间】:2020-03-23 17:54:21
【问题描述】:

我想在 itext pdf 中显示所有格式的 oracle clob 数据。 目前我正在使用以下代码来显示它。

java.sql.Clob clob=rs.getClob("MESSAGE");
Reader r = clob.getCharacterStream();
char clobVal[] = new char[(int) clob.length()];
r.read(clobVal);
StringWriter sw = new StringWriter();
sw.write(clobVal);
//add some detail information about the country
doc.add(new Paragraph("Country Code: " + sw.toString(), bf12));

上面的代码只显示字符串,但没有文本格式或 html 格式数据。请帮忙。

【问题讨论】:

  • 你的 clob 数据里面有什么?能给个样品吗?
  • 我在 CLOB 中有 html 数据。
  • 在这种情况下,您应该使用 itext 类进行 html 到 pdf 的转换。根据您回答的标签,我假设您使用 itext 5.5.x。因此,您应该使用它的XMLWorker
  • 如果您使用的是 iText 7,请使用 pdfHTML
  • 是的,我正在使用 itext 5.5 ...好的,非常感谢您,我将使用 itext 7,然后我会通知您问题是否已解决...非常感谢您的回复。跨度>

标签: java itext clob


【解决方案1】:

PDF 是二进制数据。 CLOB 是存储字符数据的。使用 BLOB,您将能够获得格式化的 PDF。

【讨论】:

    猜你喜欢
    • 2015-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    • 2023-03-16
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多