简体   繁体   English

我想使标题向左和向右对齐

[英]I want to make my header left as well as right aligned

I am trying to put some image in header of Word document through Microsoft. 我试图通过Microsoft将一些图像放在Word文档的标题中。 Office.Interop.Word. Office.Interop.Word。
I want to place the picture stretched to both boundaries of document but I am unable to do so; 我想将图片拉伸到文档的两个边界,但是我无法这样做。 whenever I set right and left indent it only changes the left indent like image is only stretched on the left side but not on the right side, Any type of help will be very precious to me. 每当我设置左右缩进时,它只会更改左缩进,就像图像仅在左侧而不是在右侧拉伸,任何类型的帮助对我来说都是非常宝贵的。 This is the snippet I am trying with: 这是我正在尝试的代码段:

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");
}

I have worked with Microsoft.interope Library. 我曾使用Microsoft.interope库。 You are doing it correctly. 您做得正确。 Unfortunately, Microsoft.interope does not provide support for stretch header. 不幸的是,Microsoft.interope不提供对拉伸标头的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM