1
从aspx页面,我使用OpenXml SDK动态地将段落添加到word文档。在这种情况下,段落内的分页符不被允许。因此,如果段落从第1页中间开始并延伸到第2页,那么它实际上应该在第2页开始。但是,如果它在同一页中结束,那没问题。OpenXml - 如何识别段落是否延伸到下一页
如何实现这一目标?有没有办法在th文档中设置段落内不允许分页符?任何输入是高度赞赏。
从aspx页面,我使用OpenXml SDK动态地将段落添加到word文档。在这种情况下,段落内的分页符不被允许。因此,如果段落从第1页中间开始并延伸到第2页,那么它实际上应该在第2页开始。但是,如果它在同一页中结束,那没问题。OpenXml - 如何识别段落是否延伸到下一页
如何实现这一目标?有没有办法在th文档中设置段落内不允许分页符?任何输入是高度赞赏。
一般而言,您的不能使用打开的xml sdk来确定页面中元素的显示位置,因为open xml没有页面的概念。
页面由客户端应用程序使用打开的xml文档确定。但是,您可以指定段落的线条保持在一起。
<w:p xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:pPr>
<w:keepLines />
</w:pPr>
<w:bookmarkStart w:name="_GoBack" w:id="0" />
<w:r>
<w:lastRenderedPageBreak />
<w:t>Most controls offer a choice of using the look from the current theme or using a format that you specify directly. To change the overall look of your document, choose new your document.</w:t>
</w:r>
<w:bookmarkEnd w:id="0" />
</w:p>
宽:keepLines在上面的例子段落属性的关键是确保一个段落不是页面之间分手了,下面是产生上述paragrpah所需的开放XML:
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
namespace GeneratedCode
{
public class GeneratedClass
{
// Creates an Paragraph instance and adds its children.
public Paragraph GenerateParagraph()
{
Paragraph paragraph1 = new Paragraph();
ParagraphProperties paragraphProperties1 = new ParagraphProperties();
KeepLines keepLines1 = new KeepLines();
paragraphProperties1.Append(keepLines1);
BookmarkStart bookmarkStart1 = new BookmarkStart(){ Name = "_GoBack", Id = "0" };
Run run1 = new Run();
LastRenderedPageBreak lastRenderedPageBreak1 = new LastRenderedPageBreak();
Text text1 = new Text();
text1.Text = "Most controls offer a choice of using the look from the current theme or using.";
run1.Append(lastRenderedPageBreak1);
run1.Append(text1);
BookmarkEnd bookmarkEnd1 = new BookmarkEnd(){ Id = "0" };
paragraph1.Append(paragraphProperties1);
paragraph1.Append(bookmarkStart1);
paragraph1.Append(run1);
paragraph1.Append(bookmarkEnd1);
return paragraph1;
}
}
}
谢谢你。你能给我一些关于如何解决这个问题的提示吗? –