如何结合WebOffice文档组件实现水印的添加
推荐于2016-04-22
展开全部
1、引入weboffice相关的文件,如:js、cab包;
2、新建html页面,引入weboffice;
3、书写测试“添加水印”的按钮
view sourceprint?
1.<input type="button" value="添加水印" onclick="AddWatermark()" />
4、编写添加水印的JS方法
view sourceprint?
01.//添加水印
02.function AddWatermark() {
03.//获取文档对象
04.var obj = document.all.WebOffice1.GetDocumentObject();
05.//选中某块区域
06.obj.Sections(1).Range.Select();
07.obj.Application.ActiveWindow.ActivePane.View.SeekView = 9;
08.//设置水印文本
09.obj.Application.Selection.HeaderFooter.Shapes.AddTextEffect(0, "www.stepday.com", "宋体", 1, false,false, 0, 0).Select();
10.obj.Application.Selection.ShapeRange.TextEffect.NormalizedHeight = 0;
11.obj.Application.Selection.ShapeRange.Line.Visible = 0;
12.obj.Application.Selection.ShapeRange.Fill.Visible = -1;
13.obj.Application.Selection.ShapeRange.Fill.Solid();
14.//填充色 为十进制颜色
15.obj.Application.Selection.ShapeRange.Fill.ForeColor.RGB = 10444703;
16.obj.Application.Selection.ShapeRange.Fill.Transparency = 0;
17.//0表示水平 315倾斜45度
18.obj.Application.Selection.ShapeRange.Rotation = 315;
19.obj.Application.Selection.ShapeRange.LockAspectRatio = -1;
20.obj.Application.Selection.ShapeRange.Height = obj.Application.CentimetersToPoints(4.92);
21.obj.Application.Selection.ShapeRange.Width = obj.Application.CentimetersToPoints(19.69);
22.obj.Application.Selection.ShapeRange.WrapFormat.AllowOverlap = true;
23.obj.Application.Selection.ShapeRange.WrapFormat.Side = 3;
24.obj.Application.Selection.ShapeRange.WrapFormat.Type = 3;
25.obj.Application.Selection.ShapeRange.RelativeHorizontalPosition = 0;
26.obj.Application.Selection.ShapeRange.RelativeVerticalPosition = 0;
27.obj.Application.Selection.ShapeRange.Left = -999995;
28.obj.Application.Selection.ShapeRange.Top = -999995;
29.obj.Application.ActiveWindow.ActivePane.View.SeekView = 0;
30.obj.Application.ActiveWindow.ActivePane.VerticalPercentScrolled = 2
31.}
2、新建html页面,引入weboffice;
3、书写测试“添加水印”的按钮
view sourceprint?
1.<input type="button" value="添加水印" onclick="AddWatermark()" />
4、编写添加水印的JS方法
view sourceprint?
01.//添加水印
02.function AddWatermark() {
03.//获取文档对象
04.var obj = document.all.WebOffice1.GetDocumentObject();
05.//选中某块区域
06.obj.Sections(1).Range.Select();
07.obj.Application.ActiveWindow.ActivePane.View.SeekView = 9;
08.//设置水印文本
09.obj.Application.Selection.HeaderFooter.Shapes.AddTextEffect(0, "www.stepday.com", "宋体", 1, false,false, 0, 0).Select();
10.obj.Application.Selection.ShapeRange.TextEffect.NormalizedHeight = 0;
11.obj.Application.Selection.ShapeRange.Line.Visible = 0;
12.obj.Application.Selection.ShapeRange.Fill.Visible = -1;
13.obj.Application.Selection.ShapeRange.Fill.Solid();
14.//填充色 为十进制颜色
15.obj.Application.Selection.ShapeRange.Fill.ForeColor.RGB = 10444703;
16.obj.Application.Selection.ShapeRange.Fill.Transparency = 0;
17.//0表示水平 315倾斜45度
18.obj.Application.Selection.ShapeRange.Rotation = 315;
19.obj.Application.Selection.ShapeRange.LockAspectRatio = -1;
20.obj.Application.Selection.ShapeRange.Height = obj.Application.CentimetersToPoints(4.92);
21.obj.Application.Selection.ShapeRange.Width = obj.Application.CentimetersToPoints(19.69);
22.obj.Application.Selection.ShapeRange.WrapFormat.AllowOverlap = true;
23.obj.Application.Selection.ShapeRange.WrapFormat.Side = 3;
24.obj.Application.Selection.ShapeRange.WrapFormat.Type = 3;
25.obj.Application.Selection.ShapeRange.RelativeHorizontalPosition = 0;
26.obj.Application.Selection.ShapeRange.RelativeVerticalPosition = 0;
27.obj.Application.Selection.ShapeRange.Left = -999995;
28.obj.Application.Selection.ShapeRange.Top = -999995;
29.obj.Application.ActiveWindow.ActivePane.View.SeekView = 0;
30.obj.Application.ActiveWindow.ActivePane.VerticalPercentScrolled = 2
31.}
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询