Unisci file PostScript in PDF utilizzando .NET

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

Aspose.Page per .NET PS Merger consente di unire file PostScript (PS) a documenti PDF utilizzando qualsiasi linguaggio supportato dalla piattaforma .NET: C#, VB, J#.
Per eseguire l’unione PS è necessario eseguire diversi passaggi:

  1. Inizializza un PsDocument con il file PS primario, ad esempio var document = new PsDocument("first.ps");.
  2. Definisci un array di stringhe contenente i percorsi dei file PS aggiuntivi da unire, ad esempio:
1string[] additionalPs = { "second.ps", "third.ps" };
  1. Crea un’istanza di PdfSaveOptions, imposta facoltativamente AdditionalFontsFolder e abilita SuppressError = true per catturare gli avvisi non critici.
  2. Aggiungi ogni file PS aggiuntivo al documento (ad esempio, foreach (var file in additionalPs) document.AddPage(file);) e quindi salva il PDF unito:
1document.Save("merged.pdf", pdfSaveOptions);
  1. Quando SuppressError è true, tutti gli avvisi vengono memorizzati in document.Exceptions; è possibile iterare questa raccolta dopo averla salvata per esaminare i problemi.


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

 1/ For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
 4// Initialize PS document with the first PostScript file
 5PsDocument document = new PsDocument(dataDir + "input1.ps");
 6
 7// Create an array of PostScript files that will be merged with the first one
 8string[] filesForMerge = new string[] { dataDir + "input2.ps", dataDir + "input3.ps" };
 9
10// If you want to convert Postscript file despite of minor errors set this flag
11bool suppressErrors = true;
12
13//Initialize options object with necessary parameters.
14PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
15// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
16options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
17
18// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
19// But if you need to specify the page size following line
20//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));
21
22document.MergeToPdf(dataDir + "outputPDF_out.pdf", filesForMerge, options);
23
24//Review errors
25if (suppressErrors)
26{
27    foreach (Exception ex in options.Exceptions)
28    {
29        Console.WriteLine(ex.Message);
30    }
31}

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