I want to add watermark to a word file with jacob,int the word file the first page has no header,but the second has it,when I add watermark as following,the first page can have watermark,but the others has no watermark,how should I do?
// 取得活动窗格对象
Dispatch activePan = Dispatch.get(activeWindow, "ActivePane").toDispatch();
// 取得视窗对象
Dispatch view = Dispatch.get(activePan, "View").toDispatch();
//输入页眉内容
Dispatch.put(view, "SeekView", new Variant(9));
Dispatch headfooter = Dispatch.get(docSelection, "HeaderFooter") .toDispatch();
//取得图形对象
Dispatch shapes = Dispatch.get(headfooter, "Shapes").toDispatch();
//给文档全部加上水印
Dispatch selection = Dispatch.call(shapes, "AddTextEffect",new Variant(24), waterMarkStr, "宋体", new Variant(1),new Variant(false), new Variant(false), new Variant(0),new Variant(0)).toDispatch();
Dispatch.call(selection, "Select");
//设置水印参数
Dispatch shapeRange = Dispatch.get(docSelection, "ShapeRange").toDispatch();
Dispatch.put(shapeRange, "Name", "PowerPlusWaterMarkObject1");
Dispatch textEffect = Dispatch.get(shapeRange,"TextEffect").toDispatch();
Dispatch.put(textEffect, "NormalizedHeight", new Boolean(false));
Dispatch line = Dispatch.get(shapeRange, "Line").toDispatch();
Dispatch.put(line, "Visible", new Boolean(false));
Dispatch fill = Dispatch.get(shapeRange, "Fill").toDispatch();
Dispatch.put(fill, "Visible", new Boolean(true));
//设置水印透明度
Dispatch.put(fill, "Transparency", new Variant(0.2));
Dispatch foreColor = Dispatch.get(fill,"ForeColor").toDispatch();
//设置水印颜色
Dispatch.put(foreColor, "RGB", new Variant(10000000));
Dispatch.call(fill, "Solid");
//设置水印旋转
Dispatch.put(shapeRange, "Rotation", new Variant(315));
Dispatch.put(shapeRange, "LockAspectRatio", new Boolean(true));
Dispatch.put(shapeRange, "Height", new Variant(117.0709));
Dispatch.put(shapeRange, "Width", new Variant(468.2835));
Dispatch.put(shapeRange, "Left", new Variant(-999995));
Dispatch.put(shapeRange, "Top", new Variant(-999995));
Dispatch wrapFormat = Dispatch.get(shapeRange, "WrapFormat").toDispatch();
//是否允许交叠
Dispatch.put(wrapFormat, "AllowOverlap", new Variant(true));
Dispatch.put(wrapFormat, "Side", new Variant(3));
Dispatch.put(wrapFormat, "Type", new Variant(3));
Dispatch.put(shapeRange, "RelativeHorizontalPosition", new Variant(0));
Dispatch.put(shapeRange, "RelativeVerticalPosition", new Variant(0));
Dispatch.put(view, "SeekView", new Variant(0));
I want to add watermark to a word file with jacob,int the word file the first page has no header,but the second has it,when I add watermark as following,the first page can have watermark,but the others has no watermark,how should I do?
the word file can be download from herehttp://www.zjzaojia.com/school/zbnotice.doc