简体   繁体   English

将Word文件中的数据设置到CK编辑器中

[英]Setting Data in to CK Editor from word file

My question is as follows. 我的问题如下。

We are using CKEditor to Show the Content of docx file inside Editor. 我们正在使用CKEditor在编辑器中显示docx文件的内容。 This CKEditor will be loaded in to our Documnentum Application. 该CKEditor将被加载到我们的Documnentum应用程序中。

I read the word file and converted it into HTML. 我阅读了word文件并将其转换为HTML。 But when I am trying to set the data of that HTML file using 但是当我尝试使用以下方法设置该HTML文件的数据时

      CKEDITOR.instances.editor1.setData('abc');

it is giving me "abc" as value in screen: 它给我“ abc”作为屏幕上的值:

<%
File file = new File("C:\\TestWordToHtml\\html\\Test.html");
BufferedReader br = null;
StringBuilder sb=new StringBuilder();

try {

    String sCurrentLine;

    br = new BufferedReader(new FileReader(file));

    while ((sCurrentLine = br.readLine()) != null) {
        sb.append(sCurrentLine);
        //System.out.println(sCurrentLine);
    }
        System.out.println("final content is"+" "+sb.toString());
} 

catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        if (br != null)br.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

String htmdata = sb.toString();`enter code here`
%>
            var abc=htmdata;

          CKEDITOR.instances.editor1.setData('abc');

Your code is... well - very poor. 您的代码...好-非常差。 You have to learn how to pass variable to JS, because in JS htmdata will be undefined . 您必须学习如何将变量传递给JS,因为在JS中htmdataundefined Then you need to pass that variable to the setData() method. 然后,您需要将该变量传递给setData()方法。 Currently you pass there 'abc' string, not abc variable. 当前,您在此处传递'abc'字符串,而不是abc变量。

So the JS part should look like this: 因此,JS部分应如下所示:

CKEDITOR.instances.editor1.setData(htmdata);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM