if ( extentionName == "doc" || extentionName == "docx")
{
//新建一个word文档对象,加载待添加水印的word文档
Document doc = new Document();
doc.LoadFromFile(Server.MapPath("/UploadFile/DescriptionWE/" + setname));
//新建一个图片水印对象并添加待设置为水印的图片
PictureWatermark picture = new PictureWatermark();
picture.Picture = System.Drawing.Image.FromFile(Server.MapPath("/skin/images/water.png"));
//根据需要设置图片的大小,然后将其设置为文档的水印
picture.Scaling = 80;
doc.Watermark = picture;
//保存文本
doc.SaveToFile(Server.MapPath("~/UploadFile/DescriptionWE/") + PFDname);
doc.Close();
if (IsEdit)
{
if (!string.IsNullOrEmpty(Article.FileUpload))
{
DeleteFileHelp.DeleteFile("~/UploadFile/DescriptionWE/" + Article.FileUpload);
}
}
Article.FileUpload = PFDname;
}
上面是我asp.netWord加水印的代码,走到PictureWatermark picture = new PictureWatermark();就停止了,是不是System.Drawing.Image.FromFile()里面我的路径写错了,请各位帮忙指正下,感谢