Unisci file XPS | Aspose.Page per Python tramite .NET

Puoi verificare la qualità di Aspose.Page XPS Merger e visualizzare i risultati tramite lo strumento online gratuito XPS Merger


Per eseguire un’unione XPS, segui questi passaggi:

  1. Inizializza un flusso di input per il primo documento XPS di input
  2. Inizializza un flusso di output per il documento XPS di output.
  3. Crea un array di file XPS che verrà unito al primo.
  4. Crea un’istanza di XpsDocument dal flusso di input creato in precedenza.
  5. Unisci i file XPS al documento creato e salvalo.


Ecco un frammento di codice di esempio che mostra come unire file XPS in un documento PDF utilizzando Python:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python
 2# The path to the documents directory.
 3data_dir = Util.get_data_dir_working_with_document_merging()
 4# Initialize the PDF output stream
 5with open(data_dir + "mergedXPSfiles.pdf", "wb") as pdf_stream:
 6    # Initialize an XPS input stream
 7    with open(data_dir + "input.xps", "rb") as xps_stream:
 8        # Load the XPS document form the stream
 9        document = XpsDocument(xps_stream, XpsLoadOptions())
10        # or load the XPS document directly from a file. No xpsStream is needed then.
11        # XpsDocument document = new XpsDocument(inputFileName, new XpsLoadOptions());
12        
13        # Initialize an options object with necessary parameters.
14        options = PdfSaveOptions()
15        
16        options.jpeg_quality_level = 100
17        options.image_compression = PdfImageCompression.JPEG
18        options.text_compression = PdfTextCompression.FLATE
19        
20        # Create a rendering device for PDF format
21        device = PdfDevice(pdf_stream)
22        
23        # Create an array of XPS files that will be merged with the first one
24        files_to_merge = [ data_dir + "Demo.xps", data_dir + "sample.xps" ]
25        
26        # Merge XPS files to output PDF document
27        document.merge(files_to_merge, device, options)

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

Il modulo di fusione XPS di Aspose.Page Python consente anche di unire file XPS a un documento PDF.

Per eseguire l’unione XPS in PDF sono necessari diversi passaggi:

  1. Inizializzare un flusso di input per il primo documento XPS in input.
  2. Inizializzare un flusso di output per il documento PDF in output.
  3. Creare un array di file XPS che verranno uniti al primo. 4. Creare un’istanza di XpsDocument dal flusso di input creato in precedenza.
  4. Specificare TextCompression, ImageCompression, JpegQualityLevel e altre opzioni di PdfSaveOptions.
  5. Creare un’istanza di PdfDevice dal flusso di output creato in precedenza.
  6. Unire i file XPS nel documento creato e salvarlo in formato PDF con le opzioni di salvataggio PDF.


Il seguente frammento di codice mostra come unire più file XPS in un documento PDF in Python:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_document_merging()
 5# Initialize an XPS output stream
 6with open(data_dir + "mergedXPSfiles.xps", "wb") as out_stream:
 7    # Initialize the XPS input stream
 8    with open(data_dir + "input.xps", "rb") as in_stream:
 9        # Load the XPS document from the stream
10        document = XpsDocument(in_stream, XpsLoadOptions())
11        # or load the XPS document directly from file. No xpsStream is needed then.
12        # XpsDocument document = new XpsDocument(inputFileName, new XpsLoadOptions());
13        
14        # Create an array of XPS files that will be merged with the first one
15        files_to_merge = [ data_dir + "Demo.xps", data_dir + "sample.xps" ]
16        
17        # Merge XPS files to the output PDF document
18        document.merge(files_to_merge, out_stream)

Vedi Unione XPS in .NET, Java e C++.

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

Valuta l’unione di file XPS online sul nostro XPS Meger.

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.