在Java中合并两个RTF文件

发布于 2024-10-06 10:03:54 字数 58 浏览 0 评论 0原文

我有两个或多个 StringWriter 形式的 rtf 文件。如何合并它们以使 RTF 标头不加倍?

I have two or more rtf files in the form of StringWriter. How can I merge them so that the RTF headers are not doubled?

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

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

发布评论

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

评论(2

深白境迁sunset 2024-10-13 10:03:54

使用 iTextRTF 库。沿着这些思路:

rtfWriter.importRtfDocument(new FileReader("testfile_in.rtf")); 

或者

RtfWriter2 rtfWriter = RtfWriter2.getInstance(
    document, new FileOutputStream("out_file.rtf")
); 
document.open(); 
rtfWriter.importRtfDocument(new FileInputStream("in_file.rtf"), null); 
document.close();

Use iTextRTF library. Something along these lines:

rtfWriter.importRtfDocument(new FileReader("testfile_in.rtf")); 

or

RtfWriter2 rtfWriter = RtfWriter2.getInstance(
    document, new FileOutputStream("out_file.rtf")
); 
document.open(); 
rtfWriter.importRtfDocument(new FileInputStream("in_file.rtf"), null); 
document.close();
青朷 2024-10-13 10:03:54

如果您不想使用第 3 方库,这里有一个替代答案,它从两个不同的 RTF 文件中读取并将它们连接成一个:
如何将 2 个 RTF 连接成一个

它具有可供您使用的完整工作代码。

If you do not want to use 3rd party libraries, here is an alternative answer that reads from two different RTF files and concatenates them into one:
How to concatenate 2 RTFs into one

It has fully working code that you could use.

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