How to Convert EPS to TIFF in C#

In this step by step tutorial, we’ll explain how to convert EPS to TIFF in C#. An EPS file is Adobe’s Encapsulated PostScript format containing the drawings. Aspose.Page for .NET lets you convert EPS to TIFF in C# code in a few steps.

The Steps to Convert EPS to TIFF in C#

  1. Install Aspose.Page for .NET package from NuGet.org
  2. Include Aspose.Page, Aspose.Page.EPS, and Aspose.Page.EPS.Device namespaces
  3. Use SetLicense method to apply API license
  4. Load EPS file into PsDocument object
  5. Create ImageDevice object using TIFF image format
  6. Set ImageSaveOptions as you prefer
  7. Save the EPS document to TIFF image device created above
  8. Read bytes array from image device and save as tiff image

From the above steps, we notice that the PsDocument object renders the EPS document as image bytes to the TIFF image device. This image device later helps us render those image bytes as TIFF image.

Code to Convert EPS to TIFF in C#

using System;
using System.IO;
using System.Drawing.Imaging;
//Add reference to Aspose.Page for .NET API
//Use following namespace to convert EPS to TIFF file type
using Aspose.Page;
using Aspose.Page.EPS;
using Aspose.Page.EPS.Device;
namespace ConvertEPSToTIFF
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before converting EPS to TIFF type
//using Aspose.Page for .NET
Aspose.Page.License AsposePageLicense = new Aspose.Page.License();
AsposePageLicense.SetLicense(@"c:\asposelicense\license.lic");
FileStream InputEPSFileToBeConverted = File.Open("EPSFileToBeConverted.eps", FileMode.Open, FileAccess.Read);
PsDocument InputEPSDocument = new PsDocument(InputEPSFileToBeConverted);
ImageDevice TiffImageDevice = new ImageDevice(ImageFormat.Tiff);
SaveOptions saveOptions = new ImageSaveOptions();
InputEPSDocument.Save(TiffImageDevice, saveOptions);
// Get image bytes array
byte[][] TiffImagesBytes = TiffImageDevice.ImagesBytes;
//loop through image bytes array and add to tiff file
int ImageBytesCount = 0;
foreach (byte[] TiffImageBytes in TiffImagesBytes)
{
using (FileStream OutputTIFFFileConverted = new FileStream("OutputConvertedTIFFFile.tiff", FileMode.Create, FileAccess.Write))
{
OutputTIFFFileConverted.Write(TiffImageBytes, 0, TiffImageBytes.Length);
}
ImageBytesCount++;
}
}
}
}

In the above code snippet, we can see that in a few steps we understood how to convert EPS to TIFF using c# code. Using this code, you can create an EPS to TIFF converter in any of your .NET applications including Web, Desktop, Windows, and Services etc.

 English