使用 iText 从 Java 生成 RTF 时,条码字体未在 MS Word 中动态加载

发布于 2024-09-29 19:10:09 字数 460 浏览 0 评论 0原文

我正在使用 iText API 使用 Java 生成 RTF。 RTF 文件生成得很好,但有一个要求是添加条形码。我所做的是:

FontFactory.register("c:\\windows\\fonts\\FREE3OF9.ttf", "Free 3 of 9 Extended");
return FontFactory.getFont("Free 3 of 9 Extended",20, Font.NORMAL, Color.BLACK);

我尝试加载其他字体;这工作正常,但当我使用条形码字体(FREE3OF9.ttf)时它不起作用。

RTF 文件已生成,但当我打开它时,MS Word 中的“字体名称”看起来像“New”而不是“Free 3 of 9 Extended”。当我选择单词并选择字体名称时,条形码显示正常。

我认为 Free 3 of 9 Extended Font 有问题。

I am using iText API to generate RTF using Java. The RTF file is generated fine but one requirement is adding a barcode. What i did is:

FontFactory.register("c:\\windows\\fonts\\FREE3OF9.ttf", "Free 3 of 9 Extended");
return FontFactory.getFont("Free 3 of 9 Extended",20, Font.NORMAL, Color.BLACK);

I tried loading other fonts; that was working fine, but it doesn't work when I use the barcode font (FREE3OF9.ttf).

The RTF file is generated but the the "Font name" looks like "New" instead of "Free 3 of 9 Extended" in MS Word when I open it. When I select the words and choose the font name, the barcode appears fine.

I think there is a problem with Free 3 of 9 Extended Font.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野の 2024-10-06 19:10:09

奇怪的。我确实没有答案,但我当然可以提供一些建议。

  • 检查 getFont(...) 的返回值。问题完全有可能出在注册上,而您只是恢复了默认字体。我不明白为什么它会被称为“新”,但绝对值得检查。
  • 如果这不是问题,请查看您的原始 RTF 输出。有问题的字体真的是“新的”还是微软在引入的过程中破坏了它?
    • 当您手动选择字体与您自己的字体时,请检查 MS 的 RTF 输出。
  • 获取iText 源代码,逐步查看它,看看出了什么问题。

源链接是 iText v2.1.7,这是支持 RTF 的最后一个版本。在此之前的某个时间,从事该工作的人就消失在网络中,因此我们停止了对 5.0 的支持(以及许可更改、包重命名等)。

Odd. I don't really have The Answer, but I can certainly offer some advice.

  • Check the return value from getFont(...). It's entirely possible that the problem is in registration, and you're just getting back a default font. I don't see why it'd be called "New", but definitely worth checking.
  • If that's not the problem, have a look at your raw RTF output. Is the font in question really "New" or is MS mangling it on the way in?
    • Check MS's RTF output when you manually pick the font vs your own.
  • Get the iText source, step through it, see what's wrong.

The source link is to iText v2.1.7, the last version that supported RTF. The guy who worked on it vanished into the web some time prior to that, so we stopped supporting it with 5.0 (along with the licensing change, package rename, and so forth).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文