[英]Setting Data in to CK Editor from word file
我的问题如下。
我们正在使用CKEditor在编辑器中显示docx文件的内容。 该CKEditor将被加载到我们的Documnentum应用程序中。
我阅读了word文件并将其转换为HTML。 但是当我尝试使用以下方法设置该HTML文件的数据时
CKEDITOR.instances.editor1.setData('abc');
它给我“ 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');
您的代码...好-非常差。 您必须学习如何将变量传递给JS,因为在JS中htmdata
是undefined
。 然后,您需要将该变量传递给setData()
方法。 当前,您在此处传递'abc'
字符串,而不是abc
变量。
因此,JS部分应如下所示:
CKEDITOR.instances.editor1.setData(htmdata);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.