C# 添加Word页眉、页脚

 时间:2024-10-12 22:46:13

1、一、添加文本、图片页眉【C#】using Spire.Doc;using Spire.Doc.Documents;using System.Drawing;using Spire.Doc.Fields;namespace AddHeaderAndFooter{ class Program { static void Main(string[] args) { //创建一个Document类实例,添加section和Paragraph Document document = new Document(@"C:\Users\Administrator\Desktop\Test.docx"); Section sec = document.AddSection(); Paragraph para = sec.AddParagraph(); //声明一个HeaderFooter类对象,添加页眉、页脚 HeaderFooter header = sec.HeadersFooters.Header; Paragraph headerPara = header.AddParagraph(); HeaderFooter footer = sec.HeadersFooters.Footer; Paragraph footerPara = footer.AddParagraph(); //添加图片和文本到页眉,并设置文本格式 DocPicture headerImage = headerPara.AppendPicture(Image.FromFile(@"C:\Users\Administrator\Desktop\2.jpg")); TextRange TR = headerPara.AppendText("The Word Trade Organization, WTO"); TR.CharacterFormat.FontName = "Andalus"; TR.CharacterFormat.FontSize = 12; TR.CharacterFormat.TextColor = Color.Green; TR.CharacterFormat.Bold = false; headerImage.TextWrappingType = TextWrappingType.Right; //添加文本到页脚,并设置格式 TR = footerPara.AppendText("The World Trade Organization is an intergovernmental organization that regulates international trade.The WTO officially commenced on 1 January 1995 under the Marrakesh Agreement, signed by 123 nations on 15 April 1994, replacing the General Agreement on Tariffs and Trade, which commenced in 1948. "); TR.CharacterFormat.Bold = false; TR.CharacterFormat.FontSize = 9; //保存文档并运行该文档 document.SaveToFile("图文页眉.docx", FileFormat.Docx); System.Diagnostics.Process.Start("图文页眉.docx"); } }}

C# 添加Word页眉、页脚
  • css设置光标为拖动
  • 使用EXCEL如何导入SQL Server数据库的数据
  • 如何在sql server数据库中导出EXCEL表
  • Navicat premium怎么打开连接
  • project比较基准工时如何进行关闭
  • 热门搜索
    眼睛哭肿了怎么快速消肿 怎么都快乐教案 肺气肿怎么治疗 辞职申请怎么写 老是打嗝怎么办 关羽是怎么死的 好奇纸尿裤怎么样 韩非子五蠹怎么读 春节用英语怎么说 热水袋怎么注水