您的位置:首页 > 其它

Word文档中在每页右下角插入图片的解决办法.

2008-08-13 17:23 393 查看
今天接到一个任务解决一项技术问题.客户想在公文审核过程中对公文中的word文档盖章.变态的是要求在word文档的所有页面的右下角盖章,而且图章要浮动在文字上方.


经过一下午的折腾把它搞定了....


关键代码如下:

object pos = p.Rectangles[1].Range.End-1;

object rng = oWordApplic.ActiveDocument.Range(ref pos,ref pos);

//插入图片并选中

oWordApplic.Selection.InlineShapes.AddPicture(imgFile,ref LinkToFile,ref SaveWithDocument,ref rng).Select();

//将刚插入的图片转为InlineShape对象

Word.InlineShape ap = oWordApplic.Selection.InlineShapes[1];

//再转换为shape对象

Word.Shape shap = ap.ConvertToShape();

//设置浮动于文字之上

shap.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoBringInFrontOfText);

//下边的就是定位了

float xOffer = oWordApplic.ActiveDocument.PageSetup.RightMargin;

float yOffer = oWordApplic.ActiveDocument.PageSetup.BottomMargin;

shap.Left = p.Width-shap.Width-xOffer;

shap.Top = p.Height-shap.Height-yOffer;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: