Merge PS/EPS documents to PDF

.NET API solution to combine several PostScript files

 

PostScript can hold multiple pages but unlike XPS it cannot include several files in one document. The merging functionality offered by Aspose.Page API solution is developed so you can combine a few files into one. As a result, you will get a PDF file that contains the content of all PS or EPS merged files. Here you will find the code example on how to Merge PostScript with C# .NET. To see how such functionality could be implemented into web solution or to merge files online try out PS Merger .

To merge PS and EPS files, we need:

  • Aspose.Page for .NET API which is a feature-rich, powerful and easy-to-use document manipulation and conversion API for the C# platform.

  • Open the NuGet package manager, and search for Aspose.Page and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


    PM> Install-Package Aspose.Page

Steps to merge PostScript files with C# .NET.

  1. Set the path to the documents directory.
  2. Initialize the PDF output stream.
  3. Initialize the first PostScript file input stream.
  4. Create an array of PostScript files that will be merged with the first one.
  5. Initialize the options object with the necessary parameters by means of the PdfSaveOptions Class.
  6. Add a particular folder where fonts are stored if needed. The default fonts folder in the OS is always included.
  7. Specify size and image format using the PdfDevice Class if required.
  8. Merge PostScript files to the output PDF document.

C# Code to merge PS and EPS to PDF

    using Aspose.Page.EPS;
    using Aspose.Page.EPS.Device;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text; 
    // The path to the documents directory.
    string dataDir = RunExamples.GetDataDir_WorkingWithDocumentMerging();
    // Initialize PS document with the first PostScript file
    PsDocument document = new PsDocument(dataDir + "input.ps");

    // Create an array of PostScript files that will be merged with the first one
    string[] filesForMerge = new string[] { dataDir + "input2.ps", dataDir + "input3.ps" };

    // If you want to convert Postscript file despite of minor errors set this flag
    bool suppressErrors = true;

    //Initialize options object with necessary parameters.
    PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
    // If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
    options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };

    // Default page size is 595x842 and it is not mandatory to set it in SaveOptions
    // But if you need to specify the page size following line
    //PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));

    document.MergeToPdf(dataDir + "outputPDF_out.pdf", filesForMerge, options);

    //Review errors
    if (suppressErrors)
    {
        foreach (Exception ex in options.Exceptions)
        {
            Console.WriteLine(ex.Message);
        }
    }



FAQ

1. How to Merge PS/EPS files?

Set the path to the documents directory and initialize output and input streams. Create an array of PostScript files to merge and merge PostScript files. If you would better merge PS/EPS files online use our free cross-platform PS Merger .

2. What output formats are supported?

By now Aspose.Page Solution allows you to merge PostScript files into a single PDF file.

3. Is the functionality free?

The cross-platform Mergers are free, when for the API solution you can get a free Trial and then buy the product if needed.

PS What is PS File Format

PS format is one of the page description language (PDL) formats. It is capable to contain graphic as well as text information on the page. That is why the format was supported by most of the programs for image editing. The postscript file itself is a kind of instruction for printers. It contains information on what and how to print from its page.