如何使用lotusscript将文档中的文本和富文本字段转换为html?

发布于 2024-08-03 14:17:05 字数 47 浏览 6 评论 0原文

我只是想知道如何将数据库中上传的文档中的文本和富文本字段转换为 html 字段。

i just wanted to know how can i convert text and rich text fields in a document uploaded in a database to html fields.

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

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

发布评论

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

评论(2

作妖 2024-08-10 14:17:05

知道我在某处看到过它:

nsftools.com 来救援

核心诀窍是将内容保存为 MIMEParts。

示例代码已有 5 年历史,是为 R6 设计的,但 Notes 具有相当好的向后兼容性。我也有个人经验,从 MIME 到 RichText 的其他方式很简单,所以您应该没问题。

对于普通文本字段,您可能希望将其内容复制到富文本字段或使用上述链接中的功能来呈现整个文档。

Knew I'd seen it somewhere:

nsftools.com to the rescue

The core of the trick is to save the content as MIMEParts.

The sample code is 5 years old and was designed for R6 but Notes has pretty good backwards compatibility. I've also had personal experience that going the other way from MIME to RichText is straightforward so you should be ok.

For the normal text fields you may want to copy their content to a rich text field or use the feature from the above link that allows you to render entire documents.

塔塔猫 2024-08-10 14:17:05

我认为在 LotusScript 中不可能真正做到这一点。但在 Java 代理中,您可以向 Domino 服务器发出 http 请求,这基本上会强制服务器执行其渲染工作。然后,您可以捕获生成的 html 并将其存储回同一个文档或不同的文档中,等等。

如果您只想在渲染中使用特定的文本/富文本字段,只需设置一种特殊的表单来进行转换,并使用精确的格式进行转换。所需的布局和字段。然后,创建包含所有文档的视图,并添加表单公式以确保使用此新表单。然后,您可以在创建的 URL 中引用该视图来呈现每个文档。

Java 代理中的代码将如下所示:

// get the URL that will open that document
// doc is current document to convert
String docid = doc.getUniversalID();
String notesURL = "/" + DB_PATH + "/" + YOUR_VIEW + "/" + docid + "?OpenDocument";
URL docURL =new URL(notesURL);
streamIn = docURL.openStream();
str = new InputStreamReader(streamIn);
binIn = new BufferedReader (str); 

String lineNext; 
StringBuffer sb = new StringBuffer();
while ( (lineNext = binIn.readLine( )) != null ) { 
    sb.append(line);
} 
String sHTML = sb.toString();
// then store sHTML somewhere

I don't think its possible to really do this in lotusscript. But in a Java agent, you can make an http request to the Domino server, which basically forces the server to do its rendering work. Then, you can capture the resulting html and store this back into the same document, or a different one, etc.

If you only want particular text/rich text fields in the rendering, just set up a special form for the conversion with the exact layout and fields desired. Then, create a view with all documents, and add a form formula to ensure that this new form is used. Then, you can reference that view in the URL you create to render each document.

The code in your Java agent would be something like this:

// get the URL that will open that document
// doc is current document to convert
String docid = doc.getUniversalID();
String notesURL = "/" + DB_PATH + "/" + YOUR_VIEW + "/" + docid + "?OpenDocument";
URL docURL =new URL(notesURL);
streamIn = docURL.openStream();
str = new InputStreamReader(streamIn);
binIn = new BufferedReader (str); 

String lineNext; 
StringBuffer sb = new StringBuffer();
while ( (lineNext = binIn.readLine( )) != null ) { 
    sb.append(line);
} 
String sHTML = sb.toString();
// then store sHTML somewhere
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文