Fusionar archivos XPS | Aspose.Page para Python a través de .NET

Puede comprobar la calidad de Aspose.Page XPS Merger y ver los resultados a través de XPS Merger en línea de forma gratuita.


Para realizar una combinación XPS, siga estos pasos:

  1. Inicialice un flujo de entrada para el primer documento XPS de entrada.
  2. Inicialice un flujo de salida para el documento XPS de salida.
  3. Cree una serie de archivos XPS que se fusionarán con el primero.
  4. Cree una instancia de XpsDocument a partir del flujo de entrada creado anteriormente.
  5. Combine archivos XPS con el documento creado y guárdelo.


Aquí hay un fragmento de código de ejemplo que demuestra cómo fusionar archivos XPS en un documento PDF usando 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)

Ver la fusión de XPS en .NET, Java y C++.

La fusión Aspose.Page Python XPS también permite fusionar archivos XPS en documentos PDF.

Es necesario seguir varios pasos para realizar la fusión de XPS a PDF:

  1. Inicialice un flujo de entrada para el primer documento XPS de entrada.
  2. Inicialice un flujo de salida para el documento PDF de salida.
  3. Cree una serie de archivos XPS que se fusionarán con el primero.
  4. Cree una instancia de XpsDocument a partir del flujo de entrada creado anteriormente.
  5. Especifique TextCompressionImageCompressionJpegQualityLevel y otras opciones de PdfSaveOptions.
  6. Cree una instancia de PdfDevice a partir del flujo de salida creado anteriormente.
  7. Combine archivos XPS en el documento creado y guárdelo como PDF con opciones de guardar PDF.


El siguiente fragmento de código muestra cómo fusionar varios archivos XPS en un documento PDF en 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)

Ver la fusión de XPS en .NET, Java y C++.

Consideremos PdfSaveOptions. Usando esta clase podemos asignar diferentes parámetros de conversión mientras fusionamos XPS a PDF.

Evalúe la fusión de XPS en línea en nuestro XPS Meger.

Puede descargar ejemplos y archivos de datos desde GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.