Unisci file XPS | Soluzione API .NET

È possibile verificare la qualità dell’unione XPS di Aspose.Page e visualizzare i risultati tramite lo strumento online gratuito Unione XPS

Aspose.Page .NET XPS Merge consente di unire file XPS a un documento XPS utilizzando qualsiasi linguaggio supportato dalla piattaforma .NET: C#, VB, J#.
Per eseguire l’unione XPS è necessario eseguire diversi passaggi:

  1. Inizializza un XpsDocument con il file XPS primario, ad esempio var document = new XpsDocument("first.xps");.
  2. Definisci un array di stringhe contenente i percorsi dei file XPS aggiuntivi da unire, ad esempio:
1string[] additionalXps = { "second.xps", "third.xps" };
  1. Aggiungi ogni XPS aggiuntivo al documento (ad esempio, foreach (var file in additionalXps) document.AddPage(file);) e quindi salva l’XPS unito:
1document.Save("merged.xps");


Il seguente frammento di codice mostra come unire i file XPS in C#:

 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

Vedere “Unione XPS” in Java e C++.

Aspose.Page .NET XPS Merge consente anche di unire file XPS a un documento PDF.
Per eseguire l’unione XPS in PDF, è necessario eseguire diversi passaggi:

  1. Inizializza un XpsDocument con il file XPS primario, ad esempio var document = new XpsDocument("first.xps");.
  2. Definire un array di stringhe con i percorsi dei file XPS aggiuntivi da unire, ad esempio:
1string[] additionalXps = { "second.xps", "third.xps" };
  1. Creare un’istanza di PdfSaveOptions e configurare le opzioni di conversione, ad esempio:
1var pdfSaveOptions = new PdfSaveOptions();
2pdfSaveOptions.TextCompression = PdfTextCompression.Flate;
3pdfSaveOptions.ImageCompression = PdfImageCompression.Auto;
4pdfSaveOptions.JpegQualityLevel = 90;
  1. Aggiungi ogni XPS aggiuntivo al documento (ad esempio, foreach (var file in additionalXps) document.AddPage(file);) e salva il risultato come PDF:
1document.Save("merged.pdf", pdfSaveOptions);


Il seguente frammento di codice mostra come unire i file XPS a un documento PDF in C#:

 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);

Vedi Unione XPS in Java e C++.

Consideriamo PdfSaveOptions. Utilizzando questa classe possiamo assegnare diversi parametri di conversione durante l’unione di file XPS in PDF.

Valuta l’unione di XPS online sul nostro XPS Merger.

Puoi scaricare esempi e file di dati da GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.