XPS ファイルの結合 | .NET API ソリューション

Aspose.Page の XPS マージ機能の品質を確認し、結果を確認するには、無料のオンライン ツール XPS Merger をご利用ください。

Aspose.Page .NET XPS Merge を使用すると、.NET プラットフォームでサポートされている任意の言語(C#、VB、J#)を使用して、XPS ファイルを XPS ドキュメントにマージできます。
XPS マージを実行するには、いくつかの手順を実行する必要があります。

1,286 / 5,000

  1. プライマリ XPS ファイルで XpsDocument を初期化します。例: var document = new XpsDocument("first.xps");
  2. 結合する追加の XPS ファイルのパスを含む文字列配列を定義します。例:
1string[] additionalXps = { "second.xps", "third.xps" };
  1. 追加の XPS ファイルをドキュメントに追加し (例: foreach (var file in additionalXps) document.AddPage(file);)、結合した XPS を保存します。
1document.Save("merged.xps");


次のコード スニペットは、C# で XPS ファイルをマージする方法を示しています。

 1// Merge several XPS files to one XPS document.
 2
 3// Load XPS document from XPS file
 4XpsDocument document = new XpsDocument(DataDir + "input.xps", new XpsLoadOptions());
 5
 6// Create an array of XPS files that will be merged with the first one
 7string[] filesToMerge = new string[] { DataDir + "Demo.xps", DataDir + "sample.xps" };
 8
 9// Merge XPS files to output XPS document
10document.Merge(filesToMerge, OutputDir + "mergedXPSfiles.xps");
Example-MergeXPStoXPS.cs hosted with ❤ by GitHub

XPS マージについては、 Java および C++ をご覧ください。

Aspose.Page .NET XPS Merge では、XPS ファイルを PDF ドキュメントにマージすることもできます。
XPS から PDF へのマージを実行するには、いくつかの手順を実行する必要があります。

  1. プライマリ XPS ファイルで XpsDocument を初期化します。例: var document = new XpsDocument("first.xps");
  2. 結合する追加の XPS ファイルのパスを文字列配列で定義します。例:
1string[] additionalXps = { "second.xps", "third.xps" };
  1. PdfSaveOptions インスタンスを作成し、変換オプションを設定します。例:
1var pdfSaveOptions = new PdfSaveOptions();
2pdfSaveOptions.TextCompression = PdfTextCompression.Flate;
3pdfSaveOptions.ImageCompression = PdfImageCompression.Auto;
4pdfSaveOptions.JpegQualityLevel = 90;
  1. ドキュメントに各 XPS ファイルを追加し(例: foreach (var file in additionalXps) document.AddPage(file);)、結果を PDF として保存します。
1document.Save("merged.pdf", pdfSaveOptions);


次のコードスニペットは、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);

XPS の結合については、 Java および C++ をご覧ください。

PdfSaveOptions について考えてみましょう。このクラスを使用すると、XPS ファイルを PDF に結合する際に、さまざまな変換パラメータを指定できます。

XPS Merger で、XPS マージ機能をオンラインで評価できます。

サンプルとデータファイルは GitHub からダウンロードできます。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.