【发布时间】:2016-04-19 08:29:43
【问题描述】:
如何在 Aspose Java 中从 word 文档中删除特定页面?
我的要求是,我有一个 word 文档,我只需要第一页?
所以我可以删除除第一个页面之外的所有页面,或者我可以创建新文档,从文档中读取第一页并将其写入新文档。
【问题讨论】:
标签: java aspose aspose.words
如何在 Aspose Java 中从 word 文档中删除特定页面?
我的要求是,我有一个 word 文档,我只需要第一页?
所以我可以删除除第一个页面之外的所有页面,或者我可以创建新文档,从文档中读取第一页并将其写入新文档。
【问题讨论】:
标签: java aspose aspose.words
您可以使用“PageSplitter”示例项目来满足您的要求。您可以在Aspose.Words for Java examples repository at GitHub 中找到 PageSplitter 代码。请使用以下代码示例从 Word 文档中提取第一页。
//Load the document
Document doc = new Document(MyDir + "in.docx");
// Create and attach collector to the document before page layout is built.
LayoutCollector layoutCollector = new LayoutCollector(doc);
// Split nodes in the document into separate pages.
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
//Get the first page of document
Document newDoc = splitter.GetDocumentOfPage(1);
newDoc.save(MyDir + "Out.docx");
我与 Aspose 合作,担任开发人员传道者。
【讨论】: