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;
try
{
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);
imageStream.Close();
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.