有人知道如何使用openxml sdk v 2.5在wordprocessingdocument中使用框架吗?我使用openxml sdk v 2.5来编辑WPF应用程序中的docx文件。我有几个对象,如表文本和图像,我想要一个框架围绕它们,所以他们不会在页面的末尾拆分。
尝试了这个:
Frame frame = new Frame(xmlElementList);
document.MainDocumentPart.Document.AppendChild(frame);
但是在将框架添加到文档后,docx文件无效且无法在单词
中打开答案 0 :(得分:2)
您可以创建ParagraphProperties并将其添加到Paragraph中,如此
ParagraphProperties paragraphProperties = new ParagraphProperties
{
KeepNext = new KeepNext(),
FrameProperties = new FrameProperties
{
HorizontalSpace = "141",
Wrap = TextWrappingValues.Around,
HorizontalPosition = HorizontalAnchorValues.Text,
VerticalPosition = VerticalAnchorValues.Text, Y = "1"
}
};
Paragraph paragraph=new Paragraph();
paragragh.ParagraphProperties =paragraphProperties;