Convert PS, EPS, and XPS

PS, EPS, and XPS conversion with API Solution for .NET.

 

Whenever the need to convert PostScript PS and Encapsulated PostScript EPS Files and XPS documents programmatically, .NET API can do it smoothly and converts multiple files. For PS and EPS, API supports Levels 1-3 PostScript operators, and most of the EPS header comments as well as transforms PostScript documents having maximum conformity with the exception of a few font cases, and API deals with such fonts as Time New Roman.

Moreover, for XPS file transformation, API can add or remove pages, deals with canvases, paths, and glyph elements, create vector graphics shapes, and text strings, convert XPS outline items, and more.

The API solution for .NET here lets you convert files of such PDL formats as PS, EPS, and XPS programmatically, but you may find it useful to see and try cross-platform developed on these native APIs.

PostScript to PDF Conversion via C# .NET.

To convert PostScript PS and Encapsulated PostScript EPS files to PDF via .NET API you need to take the next steps:

  1. Load the PS or EPS file using the PsDocument class.
  2. Create a PdfSaveOptions object and set the conversion options you need.
  3. Call PsDocument.SaveAsPdf() with the output file path and the options object.
C# Code for PS EPS to PDF Conversion
// Convert PS file to PDF document.
// Learn more: https://docs.aspose.com/page/net/convert-ps/

// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(DataDir + "input.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 PdfSaveOptions
// But if you need to specify sizeuse following line
//PdfSaveOptions options = new PdfSaveOptions(suppressErrorsnew, Aspose.Page.Drawing.Size(595x842));
// or
//saveOptions.Size = new Aspose.Page.Drawing.Size(595x842);
//If PostScript file contains some graphics written as Type3 font glyphs, but it is not actual glyphs
//the resulting PDF may be incorrect because of default value of options.ConvertFontsToTTF = true
//Try to set this
//options.ConvertFontsToTTF = false;

// Save document as PDF
document.SaveAsPdf(OutputDir + "outputPDF_out.pdf", options);

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

PostScript to Images Conversion via C# .NET.

For any EPS/PS PostScript to image converter application, the following C# code works well, so take the next steps:

  1. Load the PS or EPS file using the PsDocument class.
  2. Create an ImageSaveOptions object and set ImageFormat to the target format.
  3. Call PsDocument.SaveAsImage() with the options object.
C# Code for PostScript to Images Conversion
// Convert PS file to PNG image.
// Learn more: https://docs.aspose.com/page/net/convert-ps/

//Outut file 
string outputFileName = "output_image.png";

// Initialize PsDocument with the name of PostScript file.
PsDocument document = new PsDocument(DataDir + "inputForImage.ps");

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

//Initialize options object with necessary parameters.
ImageSaveOptions options = new ImageSaveOptions();

//Set output image format.
options.ImageFormat = Aspose.Page.Drawing.Imaging.ImageFormat.Png;

// 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}" };

// Save PS document to an image.
document.SaveAsImage(options, OutputDir, Path.GetFileNameWithoutExtension(outputFileName));

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



FAQ

1. Can I convert Postscript with this API solution?

Aspose.Page has functionality that allows you to convert PS, XPS, and EPS files to other formats online or programmatically. If you need to transform your files instantly online you may like to use Page Description Language format files Converter cross-platform application.

2. What Page description Languages are supported by the converter?

This conversion functionality supports files with .ps, .eps, and .xps extensions. Such famous PDLs as PDF and SVG are represented as separate solutions in Aspose.products

3. Is the functionality free?

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

 

Convert XPS to Images JPG, PNG, BMP via C# .NET.

.NET API also supports XPS Conversion to Images BMP, JPG, PNG, TIFF, etc., and provides XpsDocument Class for XPS operations. To convert XPS to Image take the next steps:

  1. Load the XPS file using the XpsDocument class.
  2. Create the save options class for the target format — PngSaveOptions , JpegSaveOptions , BmpSaveOptions or TiffSaveOptions .
  3. Set rendering options such as SmoothingMode, Resolution and PageNumbers, then call XpsDocument.SaveAsImage() with the options object.
C# Code for XPS to Image Conversion
// Convert XPS file to PNG image.
// Learn more: https://docs.aspose.com/page/net/convert-xps/

//Outut file 
string outputFileName = "XPStoPNG_out.png";

// Load XPS document form the XPS file
XpsDocument document = new XpsDocument(DataDir + "input.xps", new XpsLoadOptions());

// Initialize options object with necessary parameters.
PngSaveOptions options = new PngSaveOptions()
{
    SmoothingMode = SmoothingMode.HighQuality,
    Resolution = 300,
    PageNumbers = new int[] { 1, 2, 6 }
};

// Save XPS document to the PNG image files.
document.SaveAsImage(options, OutputDir, outputFileName);
 
  

Support and Learning Resources