如何使用c#将文本与word文档中的左对齐

问题描述:

我可以使用docx dll将文本和图像添加到word文档。但是文本没有与左侧对齐,默认情况下它在文档中是合理的。默认情况下如何将文本左对齐?我需要在c#中使用Ctrl + L等任何键盘键将文本对齐到左侧。



i can add a text and an image to a word document using docx dll.but the text is not aligned to left side, its coming as justify by default in the document. how to align the text to left by default ? do i need to use any keyboard keys like Ctrl + L in c# to align the text to left side.

  Novacode.Image img = doc.AddImage(strFinalImagePath);
  Picture pic = img.CreatePicture();

  foreach (Paragraph p in doc.Paragraphs)
  {
  var valuesIndex = p.FindAll("pre_setup");
  if (valuesIndex.Count > 0)
  {
   p.Append(strText).AppendLine("").AppendPicture(pic).AppendLine("");
  //p.Direction = Novacode.Direction.LeftToRight;
   p.Alignment = Alignment.left;
   p.AppendLine("");
}
}





先谢谢



Thanks in Advance

看到这个参考,希望它有所帮助。

编程将MS Word中的文本与C#对齐的问题 [ ^ ]

http://www.e-iceblue.com/Tutorials /Spire.Doc/Spire.Doc-Program-Guide/NET-Word-Align-Text-in-Word-Document-with-C-VB.NET.html [ ^ ]

http://miracle00.blogspot.in/2012/04/set-text-alignment-with-cvbnet.html [ ^ ]
See this ref,hope it helps.
Problem with programmatically aligning text in MS Word with C#[^]
http://www.e-iceblue.com/Tutorials/Spire.Doc/Spire.Doc-Program-Guide/NET-Word-Align-Text-in-Word-Document-with-C-VB.NET.html[^]
http://miracle00.blogspot.in/2012/04/set-text-alignment-with-cvbnet.html[^]