如何给word添加水印呢,要哪种可以将水印铺满整个页面的,就跟在word文档中设置水印一样。各位大侠啊,求救啊,只要能实现有,分多多啊

解决方案 »

  1.   

     2.给Word添加水印效果
    public void show()
        {
            object Nothing = System.Reflection.Missing.Value;
            Word.ApplicationClass wordAppObj = null;
            Word.Document WordDoc = null;
            try
            {
            
                // object srcFileName = Server.MapPath("Documnets") + "/ProjectTmp.doc";
                // object dstFileName = Server.MapPath("Documnets") + "/Project.doc";
                string FileName = Server.MapPath("ImgWaterMark") + "/WaterMark_W_W.bmp";
                object srcFileName = "C:\\aa.doc";
                object dstFileName = "C:\\bb.doc";
                object obj = true;
                 wordAppObj = new Word.ApplicationClass();
                 WordDoc = wordAppObj.Documents.Open(ref srcFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
               
                this.CreateWaterMarkImg("与电子文本一致", WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Height);
                this.CreateWaterMarkImgT("", WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Height);
                Word.Shape oShape;
                WordDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
                WordDoc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
             //   WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter(DateTime.Now.ToString("yyyyMMddhhssmm"));
                object top = 36;
                oShape = WordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(FileName, ref Nothing,
                    ref Nothing, ref Nothing, ref top, ref Nothing, ref Nothing, ref Nothing);
                oShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;
                oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);
                WordDoc.SaveAs(ref dstFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);        }
            catch (Exception ex)
            {        }
            finally
            {
                WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
                wordAppObj.Quit(ref Nothing, ref Nothing, ref Nothing);
            }
        } 
     参考地址:http://www.cnblogs.com/tianshikuqi8/archive/2009/04/13/1434687.html
      

  2.   

    ImageWaterMark  下载地址 http://download.csdn.net/detail/a350752425/1809311
      

  3.   

    参考下 http://www.haogongju.net/art/949549
    试了下可以添加  但是没有平铺
        protected void Button1_Click1(object sender, EventArgs e)
        {
            WaterMarkToWord("C:\\1.jpg", "c:\\cccc.doc", "c:\\cccc.doc");
        }
        public void WaterMarkToWord(string imgName, object srcFileName, object dstFileName)
        {
            object Nothing = System.Reflection.Missing.Value;
            Microsoft.Office.Interop.Word.ApplicationClass wordAppObj = null;
            Microsoft.Office.Interop.Word.Document wordDoc = null;
            try
            {
                object obj = true;
                wordAppObj = new Microsoft.Office.Interop.Word.ApplicationClass();
                wordDoc = wordAppObj.Documents.Open(ref srcFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
                Microsoft.Office.Interop.Word.Shape oShape;
                wordDoc.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;
                wordDoc.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;
                //WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter(DateTime.Now.ToString("yyyyMMddhhssmm"));
                object left = wordDoc.ActiveWindow.Width / 4;
                object top = wordDoc.ActiveWindow.Height / 2;            oShape = wordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(imgName, ref Nothing,
                    ref Nothing, ref left, ref top, ref Nothing, ref Nothing, ref Nothing);
                oShape.WrapFormat.Type = Microsoft.Office.Interop.Word.WdWrapType.wdWrapInline;
                oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);
                wordDoc.SaveAs(ref dstFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
                wordAppObj.Quit(ref Nothing, ref Nothing, ref Nothing);
            }
        }
      

  4.   

    word里有个冲蚀选项 ,但是用程序加就不知道怎么弄了,试了下oShape.PictureFormat里面的一些属性 效果不是很明显