导读 今天小栢来给大家分享一些关于ueditor下载页面打不开方面的知识吧,希望大家会喜欢哦 ueditor下载 ueditor下载页面打不

今天小栢来给大家分享一些关于ueditor下载页面打不开方面的知识吧,希望大家会喜欢哦

ueditor下载 ueditor下载页面打不开ueditor下载 ueditor下载页面打不开


1、UEditor没有提供word的导入功能,只能说是粘贴复制。

2、另外的方案:用poi来提供word导入,思路是将word转换为html输出,再用UEditor提供的setContent()方法将html的内容添加到编辑器中。

3、这个方案有两个缺点,一是poi对word文本的格式获取必须按setContent()可接受的方式进行;二是我暂时没发现poi可以提供获取段落格式(对齐方式、缩进量)的方法。

4、可以参考以下代码,这是从网上找的(不记得网页地址了,谢谢代码原主提供)package demo;import java.io.BufferedWriter;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;import java.util.List;import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.parsers.ParserConfigurationException;import javax.xml.transform.OutputKeys;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerException;import javax.xml.transform.TransformerFactory;import javax.xml.transform.dom.DOMSource;import javax.xml.transform.stream.StreamResult;import org.apache.poi.hwpf.HWPFDocument;import org.apache.poi.hwpf.converter.PicturesManager;import org.apache.poi.hwpf.converter.WordToHtmlConverter;import org.apache.poi.hwpf.usermodel.Picture;import org.apache.poi.hwpf.usermodel.PictureType;import org.w3c.dom.Document;public class Word2Html {public static void main(String argv[]) {String htmlContent = new String();try {htmlContent = convert2Html("D://test//1.doc","D://test//1.html");} catch (Exception e) {e.printStackTrace();}System.out.println(htmlContent);}/*** 将内容写入指定路径下的html文件* @param content* @param path*/public static void writeFile(String content, String path) {FileOutputStream fos = null;BufferedWriter bw = null;try {File file = new File(path);fos = new FileOutputStream(file);bw = new BufferedWriter(new OutputStreamWriter(fos,"UTF-8"));bw.write(content);} catch (FileNotFoundException fnfe) {fnfe.printStackTrace();} catch (IOException ioe) {ioe.printStackTrace();} finally {try {if (bw != null)bw.close();if (fos != null)fos.close();} catch (IOException ie) {}}}/*** 转换为html* @param fileName* @param outPutFile* @throws TransformerException* @throws IOException* @throws ParserConfigurationException*/public static String convert2Html(String fileName, String outPutFile)throws TransformerException, IOException, ParserConfigurationException {HWPFDocument wordDocument = new HWPFDocument(new FileInputStream(fileName)); //WordToHtmlUtils.loadDoc(new FileInputStream(inputFile));WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());wordToHtmlConverter.setPicturesManager(new PicturesManager(){/*** 按建议名称保存图片*/public String savePicture( byte[] content, PictureType pictureType, String suggestedName, float widthInches, float heightInches ){return "D:/test/"+suggestedName;}} );wordToHtmlConverter.processDocument(wordDocument);//save picturesList pics = wordDocument.getPicturesTable().getAllPictures();if( pics!=null ){for(int i=0; iPicture pic = (Picture)pics.get(i);System.out.println();try {pic.writeImageContent(new FileOutputStream("D:/test/" + pic.suggestFullFileName()));} catch (FileNotFoundException e) {e.printStackTrace();}}}Document htmlDocument = wordToHtmlConverter.getDocument();ByteArrayOutputStream out = new ByteArrayOutputStream();DOMSource domSource = new DOMSource(htmlDocument);StreamResult streamResult = new StreamResult(out);TransformerFactory tf = TransformerFactory.newInstance();Transformer serializer = tf.newTransformer();serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");serializer.setOutputProperty(OutputKeys.INDENT, "yes");serializer.setOutputProperty(OutputKeys.METHOD, "html");serializer.transform(domSource, streamResult);out.close();writeFile(new String(out.toByteArray()), outPutFile);return new String(out.toByteArray());}}这个编辑器有几个函数,可以在编辑器加载完后给编辑器赋值。

5、具体你搜一下帮助文档。

6、ueditor_1_2_0-gbk完整包里面有个_examples文件夹,看哈帮助吧,里面有获得内容、写入内容、判断是否有内容等等函数都有,而且还有示例。

7、editor.getContent()editor.setContent()1、选中表格;2、选择表格工具布局选项卡,在对齐方式处,根据需要选择一种即可,如图所示。

本文到这结束,希望上面文章对大家有所帮助。