Use Java library to split documents into parts. You can integrate the extracted pages with other data and, as a result, get documents of the form and content that you require. Splitting documents into parts makes it easier to collaborate on them.
This software library provides Java developers with a set of functions to split Word, PDF, EPUB, HTML, DOCX documents into parts. Splitting text into separate files can be used to make it easier to work with sections of documents. The procedure of document splitting can be part of the technology for integrating data into automated information systems or databases.
Our library provides Java developers with all the necessary functions to extract document pages according to the specified mode. This is a stand-alone Java solution that does not need Microsoft Word, Acrobat Reader or other applications installed.
Split document content using different criteria in Java code. You can use the following page extraction modes: 'split by headings', 'split by sections', 'split page by page', 'split by page ranges'.
After splitting the document, you can export the result to the required file format using the 'Document.Save' method. You can also control how document parts are exported to HTML or EPUB formats using the 'DocumentPartSavingCallback' property, which will also allow you to redirect output streams.
Split documents easily with our solution for Java. The following example shows how to split a document using Java:
// Repository path: https://releases.aspose.com/java/repo/
// Maven, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>ver</version>
<classifier>jdk17</classifier>
</dependency>
Copy
// Repository path: https://releases.aspose.com/java/repo/
// Gradle, where 'ver' - Aspose.Words version number, for example, 24.4.
compile(group: 'com.aspose', name: 'aspose-words', version: 'ver', classifier: 'jdk17')
Copy
// Repository path: https://releases.aspose.com/java/repo/
// Ivy, where 'ver' - Aspose.Words version number, for example, 24.4.
<dependency org="com.aspose" name="aspose-words" rev="ver">
<artifact name="aspose-words" m:classifier="jdk17" ext="jar"/>
</dependency>
Copy
// Repository path: https://releases.aspose.com/java/repo/
// Sbt, where 'ver' - Aspose.Words version number, for example, 24.4.
libraryDependencies += "com.aspose" % "aspose-words" % "ver"
Copy
import com.aspose.words.*;
Document doc = new Document("Input.docx");
for (int page = 0; page < doc.getPageCount(); page++)
{
Document extractedPage = doc.extractPages(page, 1);
extractedPage.save(String.format("Output_%d.docx", page + 1));
}
We host our Java packages in Maven repositories. 'Aspose.Words for Java' is a common JAR file containing byte-code. Please follow the step-by-step instructions on how to install it to your Java developer environment.
Java SE 7 and more recent Java versions are supported. We also provide a separate package for Java SE 6 in case you are obliged to use this outdated JRE.
Our Java package is cross-platform and runs on all operating systems with JVM implementation, including Microsoft Windows, Linux, macOS, Android and iOS.
For information on optional package dependencies, such as JogAmp JOGL, Harfbuzz font engine, Java Advanced Imaging JAI, please refer to Product Documentation.