Merge PostScript files to PDF using .NET

You can check the quality of Aspose.Page PS Merger and view the results via free online PostScipt Merger

Aspose.Page for .NET PS Merger allows to merge PostScript (PS) files to PDF document with using of any language supported by .NET platform: C#, VB, J#.
It is necessary to do several steps in order to perform PS merge:

  1. Initialise a PsDocument with the primary PS file, e.g., var document = new PsDocument("first.ps");.
  2. Define a string array containing the paths of the additional PS files to merge, for example:
    1string[] additionalPs = { "second.ps", "third.ps" };
  3. Create a PdfSaveOptions instance, optionally set AdditionalFontsFolder and enable SuppressError = true to capture non‑critical warnings.
  4. Add each additional PS file to the document (e.g., foreach (var file in additionalPs) document.AddPage(file);) and then save the merged PDF:
    1document.Save("merged.pdf", pdfSaveOptions);
  5. When SuppressError is true, any warnings are stored in document.Exceptions; you can iterate this collection after saving to review the issues.


The following code snippet shows how to merge PS files to PDF document in C#:

 1// Merge several PS files to one PDF document.
 2
 3// Initialize PS document with the first PostScript file
 4PsDocument document = new PsDocument(DataDir + "input.ps");
 5
 6// Create an array of PostScript files that will be merged with the first one
 7string[] filesForMerge = new string[] { DataDir + "input2.ps", DataDir + "input3.ps" };
 8
 9// If you want to convert Postscript file despite of minor errors set this flag
10bool suppressErrors = true;
11
12//Initialize options object with necessary parameters.
13PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
14// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
15options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
16
17// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
18// But if you need to specify the page size following line
19//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));
20
21document.MergeToPdf(OutputDir + "outputPDF_out.pdf", filesForMerge, options);
22
23//Review errors
24if (suppressErrors)
25{
26    foreach (Exception ex in options.Exceptions)
27    {
28        Console.WriteLine(ex.Message);
29    }
30}
Example-MergePStoPDF.cs hosted with ❤ by GitHub

See PS merge in Java and C++.

Let’s consider PdfSaveOptions. Using this class we can assign different conversion parameters while merging PS files to PDF.

Evaluate PS merging online on our PS Merger.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.