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:
1# The path to the documents directory.
2data_dir = Util.get_data_dir_working_with_pages()
3# Create a new XPS Document
4doc = XpsDocument(data_dir + "Sample1.xps")
5
6# Insert an empty page at the beginning of the pages list
7doc.insert_page(1, True)
8
9# Save the resultant XPS document
10doc.save(data_dir + "AddPages_out.xps")
You can download examples and data files from GitHub.