C# 對Word檔案添加浮水印圖片並設定編輯密碼
來源:互聯網
上載者:User
如:/**////初始化文檔對象
Word.Document WordDoc= wordAppObj.Documents.Open(ref _filename, ref missing, ref isReadOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
/**////根據文檔對象的高度與寬度產生文檔背景的圖片
string bkpic = CreateBackGroup(WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, picFilePath);
Word.Shape oShape;
/**////建立背景浮水印圖征
WordDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
WordDoc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter("");
object top = 30;
/**////將背景浮水印圖片插入到Word
oShape = WordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(bkpic, ref missing, ref missing, ref missing, ref top, ref missing, ref missing, ref missing);
oShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;
oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);