Working with Pages in XPS file | Python
Contents
[
Hide
Show
]Page management within an XPS document involves tasks such as adding, removing, rearranging, or accessing individual pages.
Add Pages
Aspose.Page for Python via .NET provides the XpsDocument Class, which includes the set_insert_page() method for adding pages to an XPS document. The following code snippet demonstrates how to use this method to add pages to an XPS document:
1from aspose.page.xps import *
2from util import Util
3###############################################
4###### Class and Method declaration here ######
5###############################################
6
7# The path to the documents directory.
8data_dir = Util.get_data_dir_working_with_pages()
9# Create a new XPS Document
10doc = XpsDocument(data_dir + "Sample1.xps")
11
12# Insert an empty page at the beginning of the pages list
13doc.insert_page(1, True)
14
15# Save the resultant XPS document
16doc.save(data_dir + "AddPages_out.xps")
You can download examples and data files from GitHub.