word 加水印C#

来源:互联网 发布:hp8570p windows 7系统 编辑:程序博客网 时间:2024/06/10 12:24
 
  1.  private void responsewrite()
  2.     {
  3.         StringBuilder strscript = new StringBuilder();
  4.         strscript.Append(" <script language =/"vbscript/">/r/n");
  5.         strscript.Append("Set myDocApp = CreateObject(/"Word.Application/")/r/n");
  6.         strscript.Append("myDocApp.Visible = True/r/n");
  7.         strscript.Append(" myDocApp.Activate/r/n");
  8.         strscript.Append("set myDoc = myDocApp.Documents.Open(/"http://localhost:1507/Web/AppModules/SPJG/Annex/00/2008/12/30/20081230144112380.doc/")/r/n");
  9.         strscript.Append("dim water/r/n");
  10.         strscript.Append("water = /"备案号:/" + chr(13) + /"Q3301Q807757-2005/" + chr(13) + /"有效期至/" + /"2008年10月22日/"/r/n");
  11.         strscript.Append("myDocApp.ActiveDocument.Shapes.AddTextbox(1, 63.85, 53.85, 265.85, 30).Select/r/n");
  12.         strscript.Append(" myDocApp.Selection.ShapeRange.TextFrame.TextRange.Select/r/n");
  13.         strscript.Append("myDocApp.Selection.Collapse/r/n");
  14.         strscript.Append(" myDocApp.Selection.TypeText(/"备案号:Q3301Q807757-2005/")/r/n");
  15.         strscript.Append("myDocApp.Selection.ShapeRange.Fill.Visible = True/r/n");
  16.         strscript.Append("myDocApp.Selection.ShapeRange.Fill.Solid/r/n");
  17.         strscript.Append("myDocApp.Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)/r/n");
  18.         strscript.Append("myDocApp.Selection.ShapeRange.Fill.Transparency = 1/r/n");
  19.         strscript.Append(" myDocApp.Selection.ShapeRange.Line.DashStyle = 1/r/n");
  20.         strscript.Append("myDocApp.Selection.ShapeRange.Line.Style = 1/r/n");
  21.         strscript.Append("myDocApp.Selection.ShapeRange.Line.Transparency = 0/r/n");
  22.         strscript.Append(" myDocApp.Selection.ShapeRange.Line.Visible = False/r/n");
  23.         strscript.Append(" myDocApp.ActiveDocument.Sections(1).Range.Select/r/n");
  24.         strscript.Append(" myDocApp.ActiveWindow.ActivePane.View.SeekView = 9 /r/n");
  25.         strscript.Append(" myDocApp.Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect1, water, /"宋体/", 1, False, False, 0, 0).Select/r/n");
  26.         strscript.Append(" myDocApp.Selection.ShapeRange.Name = /"msoTextEffect1/"/r/n");
  27.         strscript.Append(" myDocApp.Selection.ShapeRange.TextEffect.NormalizedHeight = False/r/n");
  28.         strscript.Append(" myDocApp.Selection.ShapeRange.TextEffect.FontBold = True/r/n");
  29.         strscript.Append(" myDocApp.Selection.ShapeRange.Line.Visible = False/r/n");
  30.         strscript.Append(" myDocApp.Selection.ShapeRange.Fill.Visible = True/r/n");
  31.         strscript.Append("myDocApp.Selection.ShapeRange.Fill.Solid/r/n");
  32.         strscript.Append(" myDocApp.Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 25, 100)/r/n");
  33.         strscript.Append(" myDocApp.Selection.ShapeRange.Fill.Transparency = 0 /r/n");
  34.         strscript.Append("myDocApp.Selection.ShapeRange.Rotation = 355 /r/n");
  35.         strscript.Append(" myDocApp.Selection.ShapeRange.LockAspectRatio = True/r/n");
  36.         strscript.Append(" myDocApp.Selection.ShapeRange.Height = 50 /r/n");
  37.         strscript.Append(" myDocApp.Selection.ShapeRange.Width = 300 /r/n");
  38.         strscript.Append(" myDocApp.Selection.ShapeRange.WrapFormat.AllowOverlap = True/r/n");
  39.         strscript.Append("  myDocApp.Selection.ShapeRange.WrapFormat.Side = 3 /r/n");
  40.         strscript.Append("  myDocApp.Selection.ShapeRange.WrapFormat.Type = 3/r/n");
  41.         strscript.Append(" myDocApp.Selection.ShapeRange.RelativeHorizontalPosition = 0 /r/n");
  42.         strscript.Append("  myDocApp.Selection.ShapeRange.RelativeVerticalPosition = 0/r/n");
  43.         strscript.Append("  myDocApp.Selection.ShapeRange.Left = 70  /r/n");
  44.         strscript.Append("  myDocApp.Selection.ShapeRange.Top = 190 /r/n");
  45.         strscript.Append("  myDocApp.ActiveWindow.ActivePane.View.SeekView = 0 /r/n");
  46.         strscript.Append(" function cancel()/r/n");
  47.         strscript.Append("On Error Resume Next/r/n");
  48.         strscript.Append(" myDocApp.Quit()/r/n");
  49.         strscript.Append(" self.close()/r/n");
  50.         strscript.Append(" end function/r/n");
  51.         strscript.Append("</script>");
  52.         Response.Write(strscript);
  53.     }
原创粉丝点击