C# 如何使用.net更改word文档的字体大小
我正在使用C#和Spire.Doc开发一个应用程序,它将word文档保存为指定格式,其中包括标题处的徽标以及指定的字体大小和样式 现在,我可以使用spire.doc在标题处粘贴徽标,但我无法更改整个文档的字体样式和大小:C# 如何使用.net更改word文档的字体大小,c#,fonts,spire.doc,C#,Fonts,Spire.doc,我正在使用C#和Spire.Doc开发一个应用程序,它将word文档保存为指定格式,其中包括标题处的徽标以及指定的字体大小和样式 现在,我可以使用spire.doc在标题处粘贴徽标,但我无法更改整个文档的字体样式和大小: font size should be 10; font should be: franklin gothic demi 有人能帮我吗? 提前感谢。您需要使用 这将允许您执行以下操作: var start = this.Content.Start; var end = thi
font size should be 10;
font should be: franklin gothic demi
有人能帮我吗?
提前感谢。您需要使用
这将允许您执行以下操作:
var start = this.Content.Start;
var end = this.Content.End;
var docRange = this.Range(ref start, ref end).Select();
docRange.Font.Size = 10;
docRange.Font.Name = "Franklin Gothic Demi";
有关更多详细信息,请参阅:
编辑:
要将图像添加到标题,您需要执行以下操作:
section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]
.Shapes
.AddPicture(@"headerImage.jpg", left, top, width, height);
或:
如果您正在使用:
非常感谢…它可以工作了…现在我的疑问是,我们是否可以使用Microsoft.Office.Interop.word将图像添加到word文档的标题中???…请向我推荐一些解决方案…谢谢advance@pavanbetageri我对答案进行了编辑,以包含有关添加图像的信息。如果这解决了你的问题,你能确定接受这个答案吗?:)@RagtimeWilly…当然…我今天会试试这个代码…非常感谢much@RagtimeWilly...its工作中,我可以使用spire.doc对整个word文档执行相同的操作吗?如何使用spire.doc对整个word文档执行此操作
Document doc = new Document();
doc.LoadFromFile(@"C:\MyDoc.docx", FileFormat.Docx);
HeaderFooter header = doc.Sections[0].HeadersFooters.Header;
Image headerImage = Image.FromFile(@"C:\headerImage.png");
header.Paragraphs[0].AppendPicture(logo).TextWrappingStyle = TextWrappingStyle.Tight;
//Font name
txtRange.CharacterFormat.FontName = "Century Gothic";
//Size
txtRange.CharacterFormat.FontSize = 15;
//Underline
txtRange.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;
//Color
txtRange.CharacterFormat.TextColor = Color.Brown;
txtRange1.CharacterFormat.TextColor = Color.ForestGreen;