We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception while converting .ai to pdf

Trying to convert the .ai file to a pdf using the file path, but it is throwing an exception. I tried with the latest version of Aspose.PSD (22.12.0)

Here is my code -

public void ConvertAiImageFileToPdf()
string sourceFileName = @“D:\Fig1_NMED-A111929D.ai”;
string pdfFile = @“D:\Fig1_NMED-A111929D.pdf”;

using (AiImage image = (AiImage)Image.Load(sourceFileName))

    ImageOptionsBase options = new PdfOptions();
    image.Save(pdfFile, options);


Fig1_NMED-A111929D.zip (1.2 MB)
Here is .ai file

Please check the following code sample: https://products.aspose.com/psd/ai/ (tab code snippet)

It’s better to use Aspose.PSD to open this AI file.

// To view the new AI format please use the following code:
async Task<bool> ViewPdfToPng(Stream pdfFileStream, string pngFileId, Size size)
	pdfFileStream.Position = 0;
		using var pdfDocument = new Aspose.Pdf.Document(pdfFileStream);
		var page = pdfDocument.Pages[1];
		using var imageStream = new MemoryStream();
		Resolution resolution = new Resolution(300);
		PngDevice pngDevice = new PngDevice(size.Width, size.Height, resolution);
		pngDevice.Process(page, imageStream);
		imageStream.Position = 0;
		await StorageService.Upload(pngFileId, imageStream);
		return true;
	catch (Aspose.Pdf.InvalidPdfFileFormatException)
		return false;

// For the viewing of Old AI Formats please use the Aspose.PSD
using (AiImage image = (AiImage)Image.Load(sourceFileName))
	ImageOptionsBase options = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha };
	image.Save(outFileName, options);

Also, we have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PSDNET-1436

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@DmitriySorokin Thank you for the reply

I’m looking for a solution convert .ai files to pdf. Tried with below sample as well but it is throwing an image loading failed exception.

using (PsdImage image = (PsdImage)Image.Load(sourceFileName))
// To get the pixel-perfect PSD File Image just use this code
image.Save(sourceFileName + “.png”, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });

Can you please help me on this.

@amolm at this moment you can not make it using Aspose.PSD, because you are trying to use modern AI format, we planned to add this feature this year. Only Aspose.PDF can open this version.

Please try just rename file from name.ai to name.pdf, modern AI format is a some type of PDF and it can work in some cases.

Thank you @DmitriySorokin