[英]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.