在 XPS 文件中使用页面 | Python
Contents
[
Hide
Show
]XPS 文档中的页面管理涉及添加、删除、重新排列或访问单个页面等任务。
添加页面
Aspose.Page for Python via .NET 提供了 XpsDocument 类,其中包含用于向 XPS 文档添加页面的 set_insert_page() 方法。以下代码片段演示了如何使用此方法向 XPS 文档添加页面:
1from aspose.page.xps import *
2from util import Util
3# The path to the documents directory.
4data_dir = Util.get_data_dir_working_with_pages()
5# Create a new XPS Document
6doc = XpsDocument(data_dir + "Sample1.xps")
7
8# Insert an empty page at the beginning of the pages list
9doc.insert_page(1, True)
10
11# Save the resultant XPS document
12doc.save(data_dir + "AddPages_out.xps")您可以从 GitHub下载示例和数据文件。