合并 XPS 文件 | Aspose.Page for Java

您可以通过免费在线工具 XPS Merger

检查 Aspose.Page XPS Merger 的质量并查看结果。

Aspose.Page Java XPS Merger 允许在任何支持 Java 虚拟机的操作系统上将 XPS 文件合并为 XPS 文档。
执行 XPS 合并需要执行以下几个步骤:

  1. 从第一个 XPS 文件创建 XpsDocument 实例。
  2. 创建一个将与第一个 XPS 文件合并的 XPS 文件数组。
  3. 将 XPS 文件与创建的文档合并并保存。


以下代码片段展示了如何在 Java 中将 XPS 文件合并为 PDF 文档:

 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// Load the first XPS file in a document
 5XpsDocument document = new XpsDocument(dataDir + "input.xps");
 6
 7// Create an array of XPS files that will be merged with the first one
 8String[] filesForMerge = new String[] { dataDir + "Demo.xps", dataDir + "sample.xps" };
 9
10//merge and save to output XPS file
11document.merge(filesForMerge, dataDir + "mergedXPSfiles.xps");

请参阅 .NETC++ 中的 XPS 合并。

Aspose.Page Java XPS 合并器也允许将 XPS 文件合并为 PDF 文档。
执行 XPS 到 PDF 合并需要执行以下几个步骤:

  1. 从第一个 XPS 文件创建 XpsDocument 实例。
  2. 创建一个将与第一个 XPS 文件合并的 XPS 文件数组。
  3. 指定 PdfSaveOptionsTextCompressionImageCompressionJpegQualityLevel 和其他选项。
  4. 将 XPS 文件与创建的文档合并,并使用 PDF 保存选项将其保存为 PDF。


以下代码片段展示了如何在 Java 中将 XPS 文件合并为 PDF 文档:

 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// Load the first XPS file in a document
 6XpsDocument document = new XpsDocument(dataDir + "input.xps");
 7
 8// Create an array of XPS files that will be merged with the first one
 9String[] filesForMerge = new String[] { dataDir + "Demo.xps", dataDir + "sample.xps" };
10
11// Initialize options object with necessary parameters.
12com.aspose.xps.rendering.PdfSaveOptions options = new com.aspose.xps.rendering.PdfSaveOptions();
13options.setJpegQualityLevel(100);
14options.setImageCompression(com.aspose.xps.rendering.PdfImageCompression.Jpeg);
15options.setTextCompression(com.aspose.xps.rendering.PdfTextCompression.Flate);
16options.setPageNumbers(new int[] { 1, 2, 6 });
17
18document.mergeToPdf(filesForMerge, dataDir + "XPStoPDF.pdf", options);

请参阅 .NETC++ 中的 XPS 合并。

我们来看一下 PdfSaveOptions。使用这个类,我们可以在将 XPS 合并为 PDF 时指定不同的转换参数。

在我们的 XPS Meger 上在线评估 XPS 合并。

您可以从 GitHub 下载示例和数据文件。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.