Unisci file PostScript in PDF utilizzando Java

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

Aspose.Page per Java PS Merger consente di unire file PostScript (PS) a documenti PDF su qualsiasi sistema operativo che supporti Java Virtual Machine.
Per eseguire l’unione di file PS in PDF, è necessario eseguire diversi passaggi:

  1. Creare un’istanza di PsDocument dal primo file PostSctipt.
  2. Creare un array di file PostSctipt che verranno uniti al primo. 3. Utilizzare PdfSaveOptions per specificare i valori booleani AdditionalFontsFolder e SuppressError.
  3. Unire i file PS al documento creato e salvarlo in formato PDF con le opzioni di salvataggio PDF.
  4. Se il valore SuppressErrors è impostato su true, come predefinito, è possibile visualizzare gli errori generati durante l’unione dei file EPS in un documento PDF e salvati nell’elenco Eccezioni.


Il seguente frammento di codice mostra come unire i file PS in un documento PDF in Java:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
 2
 3        // The path to the documents directory.
 4        String dataDir = Utils.getDataDir();
 5
 6				// Initialize PS document from PostScript file.
 7        PsDocument document = new PsDocument(dataDir + "input.ps");
 8        
 9        // Create an array of PostScript files that will be merged with the first one
10        String[] filesForMerge = new String[] { dataDir + "input2.ps", dataDir + "input3.ps" };
11
12        // If you want to merge PostScript file despite of minor errors set this flag
13        boolean suppressErrors = true;
14
15        //Initialize options object with necessary parameters.
16        PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
17        // If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
18        //options.setAdditionalFontsFolders(new String [] {"FONTS_FOLDER"});
19        // Default page size is 595x842 and it is not mandatory to set it in PdfSaveOptions
20        // But if you need to specify size use following line
21        // PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Dimension(595, 842));
22
23        // Merge files with initialized PsDocument and save it as PDF
24        document.mergeToPdf(dataDir + "mergePStoPDF.pdf", filesForMerge, options);
25
26        //Review errors
27        if (suppressErrors) {
28            for (Exception ex : options.getExceptions()) {
29                System.out.println(ex.getMessage());
30            }
31        }

Vedi Unione PS in .NET 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 Unione PS.

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.