MS Word文档中没有Page的概念。页面是由Microsoft Word即时创建的,不幸的是,没有可用于设置每个页面方向的直接方法。但是,您可以使用Section.PageSetup.Orientation属性为整个Section指定方向设置,并且Section可能包含多个页面。
或者,您可以使用Aspose.Words在Word文档中为每个页面创建一个单独的Section,然后为与特定页面相对应的每个Section指定页面方向。请在Aspose.Words论坛中报告此要求,然后我们将为该要求开发代码并为您提供更多信息。
编辑:
如果要从头开始构建文档,请使用以下代码:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Content on first page");
builder.getPageSetup().setOrientation(Orientation.PORTRAIT);
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln("Content on second page");
builder.getPageSetup().setOrientation(Orientation.LANDSCAPE);
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln("Content on third page");
builder.getPageSetup().setOrientation(Orientation.PORTRAIT);
doc.save(getMyDir() + "15.10.0.docx");
我与Aspose一起担任开发人员推广人员。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句