Unisci file PostScript in PDF tramite Python

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


Esegui i seguenti semplici passaggi per combinare diversi file PS in un unico PDF tramite Python:

  1. Inizializza un flusso di input per il primo file PS di input.
  2. Inizializza un flusso di output per il documento PDF di output.
  3. Crea un array di file PS che verrà unito al primo.
  4. Crea un’istanza di PsDocument dal flusso di input creato in precedenza. 5. Utilizzare PdfSaveOptions per specificare i valori booleani AdditionalFontsFolder e SuppressError.
  5. Creare un’istanza di PdfDevice dal flusso di output creato in precedenza.
  6. Unire i file PostScript al documento creato e salvarlo in PDF con le opzioni di salvataggio in PDF.


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

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

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

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