UEditor文档
http://fex.baidu.com/ueditor/
官网下载 UEditor
https://github.com/fex-team/ueditor
打印的方式有很多,这里其实注重于训练如何使用ueditor。
把编辑器的状态栏和工具栏全部隐藏,仅仅让其作为一个现实的工具,然后调用其打印方法进行打印。
下载压缩包ueditor-dev-1.5.0.zip,解压后_examples就是示例页面,在该文件夹下新建一个html名为printDemo.html
代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>打印demo</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="../ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="editor_api.js"> </script>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../lang/zh-cn/zh-cn.js"></script>
<style type="text/css">
div{
width:100%;
}
</style>
</head>
<body>
<div>
<h1>打印demo</h1>
<script id="editor" type="text/plain" style="width:1024px;height:200px;"></script>
<br><br>
<button onclick="uePrint()"> 打 印 </button>
</div>
<script type="text/javascript">
//实例化编辑器
var ue = UE.getEditor('editor',{
readonly : true,
open_toolbar: '',
toolbars: {},
toolbar_plugins: '',
wordCount:false,
elementPathEnabled : false
});
ue.ready(function() {
ue.setContent('以热爱祖国为荣,以危害祖国为耻。<br>'+
'以服务人民为荣,以背离人民为耻。<br>'+
'以崇尚科学为荣,以愚昧无知为耻。<br>'+
'以辛勤劳动为荣,以好逸恶劳为耻。<br>'+
'以团结互助为荣,以损人利己为耻。<br>'+
'以诚实守信为荣,以见利忘义为耻。<br>'+
'以遵纪守法为荣,以违法乱纪为耻。<br>'+
'以艰苦奋斗为荣,以骄奢淫逸为耻。');
});
function uePrint(){
ue.execCommand('print');
}
</script>
</body>
</html>
效果如下
点击打印按钮会调用ueditor的打印事件进行处理。