javascript vbscript 从 rtf 转换为 html
有谁知道 RTF 到 HTML 转换器的任何 vbscript / javascript 实现吗?
我在 VB / c# 中看到过一些,但找不到任何对脚本版本的引用。在我开始写一个之前 - 有谁知道现有的开源项目可以处理这个问题吗?
非常感谢,
弗兰科
Does anyone know of any vbscript / javascript implementations of a RTF to HTML converter?
I have seen some in VB / c#, but cannot find any reference to a scripted version. Before I start to write one - does anyone know of an existing open source project that deals with this?
Many thanks,
Franko
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
弗兰克 -
您没有指定您的目标平台。然而,您提到 VBScript 和 Javascript 的事实表明您至少使用的是基于 Windows 的计算机。如果是这样,并且您可以访问某个版本的 Word,则可以使用脚本自动执行转换,并将 Word 用作进程外服务器。即使如此,您也没有真正说明这是通过 Windows 会话还是通过 Web 服务器完成的。
如果您想从 Windows 会话中执行此操作,您可以使用以下由 Windows 脚本主机运行的 VBScript:
[Rtf2Html.vbs]
如果您想从 Web 服务器中使用它,事情就是有点不同。您可以针对 ASP 页面调整 VBScript,或将其转换为 ASP.NET 页面。无论如何,您都必须用适当的内部对象替换 WSH 对象。但是,请注意:虽然可以使用 IIS 中的进程外服务器,但这通常是一个坏主意,除非您知道这将是一个容量极小的服务器。即使如此,Word 可能使用 GUI 元素这一事实也带来了潜在的危险,因为 Word 可能会在某些错误情况下显示对话。
在这种情况下,最好通过从服务器脚本 shell 到 Windows 脚本主机代码来断开两个进程的连接,并在适当的延迟后返回一个执行客户端拉取的页面。
Frank -
You didn't specify which platform you are targeting. However, the fact you mentioned VBScript as well as Javascript suggests you are at the least using a Windows-based machine. If so, and you have access to a version of Word, you could use a script automating a conversion, using Word as an out of process server. Even then, you didn't really say whether this is meant to be done from a Windows session, or via a web server.
If you wanted to do this from a Windows session, you could use the following VBScript, run by the Windows Scripting Host:
[Rtf2Html.vbs]
If you want to use this from a webserver, things are a little different. You could adapt the VBScript for an ASP page, or convert it to an ASP.NET page. In any case, you will have to replace the WSH objects with the appropriate internal objects. However, be warned: whilst it is possible to use an out of process server from IIS, it is generally a bad idea, unless you know this is going to be an extremely low volume server. Even then, the fact that Word potentially uses GUI elements makes this potentially dangerous, because it is possible that Word might show a dialogue in some error condition.
In this case, it may be better to disconnect the two processes by shelling out from the server script to the Windows scripting host code, and instead return a page that does a client side pull after an appropriate delay.
您对 PHP 的熟悉程度如何?这个类似乎可以解决问题,因此您可以按原样使用它,或者转换为 Javascript,甚至可以用作指南。
http://pastebin.ca/1688799
How comfortable are you with PHP? This class seems to do the trick, so you could either use it as is, or convert to Javascript, or even use as a guideline.
http://pastebin.ca/1688799