使用 html textarea 或类似的东西在浏览器显示中显示/渲染 RTF 文档

发布于 2025-01-06 15:29:44 字数 366 浏览 0 评论 0原文

我的 Web 应用程序有一个功能,其中预格式化的 RTF 文档用作模板,用户可以选择数据源,然后与 RTF 文档模板合并以创建合并的 RTF 文件。 RTF 模板具有占位符,这些占位符会替换为用户选择的内容。如果本地用户计算机上有 Word/写字板,则可以保存或直接打开最终文档。

现在,我需要将合并后的文档显示给用户进行确认。用户可以直接打印或将文档保存到系统中。显示不应该是单词/写字板应用程序,而应该在应用程序本身内,使用文本区域或类似的东西来呈现文档。您能否告诉我是否可以在文本区域中呈现 RTF 文档。除了显示的内容之外,还应该有打印和保存文档的选项。如果我必须将 RTF 转换为 Html,然后在 textarea 中显示 html 内容,请告诉我如何进行转换,然后显示 html在页面中。

My web application has an feature wherein preformatted RTF documents are used as templates and the user can select the source of data and then merge with the RTF documents templates to create merged RTF files. The RTF templates have placeholders which get replaced with user selected content. The final doc can either be saved or opened directly if word/wordpad is available on the local users machine.

Now, I have a requirement to display the merged document to the user for confirmation. The user may either print or save the document to the system directly. The display should not be word/wordpad application but should be within the application itself, using textarea or something similar to render the document. Can you please let me know if its possible to render the RTF document in textarea or not. Along with the displayed content, there should be options to print and save the document.If I have to convert the RTF to Html and then display the html content in textarea , please let me know how i can do the conversion and then display the html in the page.

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

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

发布评论

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

评论(2

忆悲凉 2025-01-13 15:29:44

这是一个非常困难的要求。首先,让我们放弃关于

其次,没有浏览器可以直接显示 RTF。您可以将其嵌入为 ,有些可能会显示它(IE 可能会),但我不能说哪些不会。便携式设备几乎肯定不会。但你应该测试一下这个,也许它毕竟工作得足够好。

如果做不到这一点,HTML 转换也是不可能的,因为 RTF 有非常非常多的功能无法在 HTML 中模拟。有一些转换器(谷歌),但它们都有严重的限制。如果您想要全面的支持,您将必须通过 Canvas 或 Flash 等进行自己的渲染。

为此,我建议查看 Google 文档。他们已经经历了所有这些麻烦,并拥有一个功能相当齐全的引擎来显示大多数可能的文档。我认为也可以将它们嵌入到您自己的网页中,尽管我自己从未检查过。

That's a very difficult requirement. First of all, let's dismiss the idea about a <textarea>, because it does not support any formatting at all. All the WYSIWYG editors you've seen out there are based on <iframe>s.

Secondly, no browser can directly display a RTF. You can embed it as an <object>, and some might show it (IE probably will), but I can't say which ones won't. Portable devices almost certainly won't. But you should test this though, maybe it works well enough after all.

Failing that, HTML conversion is also out of question, because RTF has very very many features that cannot be emulated in HTML. There are some converters out there (google), but but they will all come with serious limitations. If you want full support, you will have to do your own rendering via Canvas or Flash or something.

To this end I'd suggest checking out Google Docs. They've gone through all of this hassle and have a rather feature-full engine for displaying most possible documents. I think it was also possible to embed them in your own webapges, though I've never checked it out myself.

¢蛋碎的人ぎ生 2025-01-13 15:29:44

使用

 标签在浏览器中显示/渲染 RTF 文档。

Use a <PRE> tag to Display/Render RTF doc in browser.

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