2016-04-19 8 views
1

Aspose Javaのワードドキュメントから特定のページを削除するには?Aspose Javaのワードドキュメントから特定のページを削除するには?

私の要件は、私は最初のページだけが必要な単語の文書が1つありますか?

最初のページを除くすべてのページを削除することも、新しいドキュメントを作成して最初のページをドキュメントから読み込んで新しいドキュメントに書き込むこともできます。

答えて

0

"PageSplitter"サンプルプロジェクトを使用して要件を満たすことができます。 PageScripコードはAspose.Words for Java examples repository at GitHubにあります。次のコード例を使用して、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 as Developerエバンジェリストを使用しています。

+0

解決策はうまくいきますが、私はいくつかの単語文書の機能を失っています。分割後、私は差し込みフィールドを失っています。 –

+0

調査のため、[Aspose.Words forum](http://www.aspose.com/community/forums/aspose.words-product-family/75/showforum.aspx)に問題の詳細を投稿してください。 Asposeの開発者エバンジェリストとして働いています。 –

関連する問題