我想让 header 左对齐和右对齐
I want to make my header left as well as right aligned
我正在尝试通过 Microsoft 将一些图像放入 header 的 Word 文档中。 Office.Interop.Word.
我想将图片拉伸到文档的两个边界,但我无法这样做;每当我设置左右缩进时,它只会改变左缩进,就像图像只在左侧拉伸而不在右侧拉伸一样,任何类型的帮助对我来说都是非常宝贵的。这是我正在尝试的片段:
foreach (Microsoft.Office.Interop.Word.Section wordSection in docWord.Sections)
{
wordSection.PageSetup.HeaderDistance = 0;
Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
//footerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
//footerRange.ParagraphFormat.LeftIndent = -(docWord.Application.CentimetersToPoints(3));
footerRange.InlineShapes.AddPicture(@"C:\test\footer.png");
Microsoft.Office.Interop.Word.Range headerRange = wordSection.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
//headerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
MessageBox.Show((headerRange.ParagraphFormat.RightIndent - (docWord.Application.CentimetersToPoints(72))).ToString());
//headerRange.ParagraphFormat.RightIndent = (docWord.Application.InchesToPoints(-1));
//headerRange.ParagraphFormat.LeftIndent = -(docWord.Application.CentimetersToPoints(3));
headerRange.ParagraphFormat.FirstLineIndent = -(docWord.Application.CentimetersToPoints(3));
//MessageBox.Show(headerRange.ParagraphFormat.RightIndent.ToString());
//headerRange.ParagraphFormat.SpaceBefore =0 ;
headerRange.InlineShapes.AddPicture(@"C:\test\header.png");
}
我曾在 Microsoft.interope 图书馆工作过。你做得对。遗憾的是,Microsoft.interope 不支持拉伸 header。
我正在尝试通过 Microsoft 将一些图像放入 header 的 Word 文档中。 Office.Interop.Word.
我想将图片拉伸到文档的两个边界,但我无法这样做;每当我设置左右缩进时,它只会改变左缩进,就像图像只在左侧拉伸而不在右侧拉伸一样,任何类型的帮助对我来说都是非常宝贵的。这是我正在尝试的片段:
foreach (Microsoft.Office.Interop.Word.Section wordSection in docWord.Sections)
{
wordSection.PageSetup.HeaderDistance = 0;
Microsoft.Office.Interop.Word.Range footerRange = wordSection.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
//footerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
//footerRange.ParagraphFormat.LeftIndent = -(docWord.Application.CentimetersToPoints(3));
footerRange.InlineShapes.AddPicture(@"C:\test\footer.png");
Microsoft.Office.Interop.Word.Range headerRange = wordSection.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
//headerRange.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkRed;
MessageBox.Show((headerRange.ParagraphFormat.RightIndent - (docWord.Application.CentimetersToPoints(72))).ToString());
//headerRange.ParagraphFormat.RightIndent = (docWord.Application.InchesToPoints(-1));
//headerRange.ParagraphFormat.LeftIndent = -(docWord.Application.CentimetersToPoints(3));
headerRange.ParagraphFormat.FirstLineIndent = -(docWord.Application.CentimetersToPoints(3));
//MessageBox.Show(headerRange.ParagraphFormat.RightIndent.ToString());
//headerRange.ParagraphFormat.SpaceBefore =0 ;
headerRange.InlineShapes.AddPicture(@"C:\test\header.png");
}
我曾在 Microsoft.interope 图书馆工作过。你做得对。遗憾的是,Microsoft.interope 不支持拉伸 header。