Working with Pages in XPS file | Java
Contents
[
Hide
Show
]Add Pages
Aspose.Page for Java offers XpsDocument Class, which exposes setInsertPage() method that can be used to add pages to XPS document. Following code snippet shows complete functionality to add pages to XPS document:
1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
2// The path to the documents directory.
3String dataDir = Utils.getDataDir();
4
5// Create new XPS Document
6XpsDocument doc = new XpsDocument(dataDir + "Aspose.xps");
7
8// Insert an empty page at beginning of pages list
9doc.insertPage(1, true);
10
11// Save resultant XPS document
12doc.save(dataDir + "AddPages_out.xps");
You can download examples and data files from GitHub.