合并 XPS 文件 | .NET API 解决方案

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

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

Aspose.Page .NET XPS Merge 允许使用 .NET 平台支持的任何语言(例如 C#、VB 和 J#)将 XPS 文件合并为 XPS 文档。
执行 XPS 合并需要执行以下几个步骤:

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


以下代码片段展示了如何在 C# 中合并 XPS 文件:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Load XPS document from XPS file
 5XpsDocument document = new XpsDocument(dataDir + "input1.xps", new XpsLoadOptions());
 6
 7// Create an array of XPS files that will be merged with the first one
 8string[] filesToMerge = new string[] { dataDir + "input2.xps", dataDir + "input3.xps" };
 9
10// Merge XPS files to output XPS document
11document.Merge(filesToMerge, dataDir + "mergedXPSfiles.xps");

请参阅 JavaC++ 中的 XPS 合并。

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

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


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

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Load XPS document form the XPS file
 5XpsDocument document = new XpsDocument(dataDir + "input1.xps", new XpsLoadOptions());
 6
 7// Initialize options object with necessary parameters.
 8Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions options = new Aspose.Page.XPS.Presentation.Pdf.PdfSaveOptions()
 9{
10    JpegQualityLevel = 100,
11    ImageCompression = Aspose.Page.XPS.Presentation.Pdf.PdfImageCompression.Jpeg,
12    TextCompression = Aspose.Page.XPS.Presentation.Pdf.PdfTextCompression.Flate
13};
14
15// Create an array of XPS files that will be merged with the first one
16string[] filesToMerge = new string[] { dataDir + "input2.xps", dataDir + "input3.xps" };
17
18// Merge XPS files to output PDF file
19document.MergeToPdf(dataDir + "mergedXPSfiles.pdf", filesToMerge, options);

请参阅 JavaC++ 中的 XPS 合并。

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

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

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

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.