Unisci file EPS in PDF usando Python

È possibile verificare la qualità di Aspose.Page EPS Merger e visualizzare i risultati tramite EPS Merger online gratuito

Aspose.Page per Python tramite .NET EPS Merger consente di unire file Encapsulated PostScript (EPS) in un documento PDF su qualsiasi sistema operativo in cui sia presente la Python Virtual Machine.

Per eseguire l’unione di file EPS in PDF, sono necessari diversi passaggi:

  1. Inizializzare un flusso di input per il primo file EPS di input.
  2. Inizializzare un flusso di output per il documento PDF di output.
  3. Creare un array di file EPS da unire al primo.
  4. Creare un’istanza di PsDocument dal flusso di input creato in precedenza.
  5. Utilizzare PdfSaveOptions per specificare i valori booleani AdditionalFontsFolder e SuppressError.
  6. Creare un’istanza di PdfDevice dal flusso di output creato in precedenza.
  7. Unire i file EPS al documento creato e salvarlo come PDF con le opzioni di salvataggio PDF specificate.


Il seguente frammento di codice mostra come unire i file EPS 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
 3from aspose.page.eps import *
 4from aspose.page.eps.device import *
 5from util import Util
 6###############################################
 7###### Class and Method declaration here ######
 8###############################################
 9
10# The path to the documents directory.
11data_dir = Util.get_data_dir_working_with_document_merging()
12# Initialize a PDF output stream
13pdf_stream = open(data_dir + "outputPDF_out.pdf", "wb")
14# Initialize the first PostScript file input stream
15ps_stream = open(data_dir + "input.eps", "rb",)
16document = PsDocument(ps_stream)
17
18# Create an array of PostScript files that will be merged with the first one
19files_for_merge = [ data_dir + "input2.eps", data_dir + "input3.eps" ]
20
21# If you want to convert the Postscript file despite of minor errors set this flag
22suppress_errors = True
23
24# Initialize options object with the necessary parameters.
25options = PdfSaveOptions(suppress_errors)
26# If you want to add a special folder where fonts are stored. Default fonts folder in OS is always included.
27options.additional_fonts_folders = [ """{FONT_FOLDER}""" ]
28
29# Default page size is 595x842 and it is not mandatory to set it in PdfDevice
30device = PdfDevice(pdf_stream)
31# But if you need to specify size and image format use following line
32#Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new aspose.pydrawing.Size(595, 842));
33
34try:
35    document.merge(files_for_merge, device, options)
36finally:
37    ps_stream.close()
38    pdf_stream.close()

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

Consideriamo PdfSaveOptions, che consente di impostare diversi parametri di conversione durante l’unione di file EPS in PDF.

Valuta l’unione EPS online sul nostro EPS 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.