0

如何在word文档的页眉中插入图片。我编写了一个插件,用于在实体中附加文档时重命名。如何在保存文件之前在 word 文档的标题中插入徽标。c# 中的代码也会对我有所帮助。

4

2 回答 2

3

您可以使用此代码在 word 文档的标题中插入图像:

 foreach (wd.Section section in CurrentDocument.Sections)
 {
  word.HeaderFooter header= section.Headers[wd.WdHeaderFooterIndex.wdHeaderFooterPrimary];
  wd.Shape oshape = header.Shapes.AddPicture(@"C:\Users\mahammadi\Desktop\icon\plus2.png",  left, top, width, height);
 }
于 2012-09-01T08:23:59.260 回答
0
  Document doc = new Document();
  doc.LoadFromFile(@"E:\JaneEyre.docx", FileFormat.Docx);
 HeaderFooter header = doc.Sections[0].HeadersFooters.Header;
  header.Paragraphs[0].Text = "Preview";
  Image logo = Image.FromFile(@"D:\E-ICEBLUE.png");
  header.Paragraphs[0].AppendPicture(logo).TextWrappingStyle = TextWrappingStyle.Tight;
  HeaderFooter footer = doc.Sections[0].HeadersFooters.Footer;
  doc.SaveToFile("Sample.docx", FileFormat.Docx);
  System.Diagnostics.Process.Start("Sample.docx");footer.Paragraphs[0].Text = "Author: Charlotte Brontë";
于 2012-08-31T05:40:48.107 回答