Object reference is not set to an instance of the object on jpegDevice.Process()

Greetings,

I had spoken with Babar Raza on the support chat momentarily ago. We are currently having an issue with the jpegDevice.Process() function. We are using the C# code from this sample:

https://docs.aspose.com/pdf/net/convert-pdf-to-images-format/

Upon running the sample (after appropriately adding our temporary license and setting variables appropriately) the jpegDevice.Process() errors out with “object reference is not set to an instance of the object”. Unfortunately we cannot step through the bug as it appears to be with the API.

The PDF in question that we are using as a sample was created with the API. I have attached it to this post.

I was also told to link to our source code here. Everything works fine until jpegDevice.Process.

//var doc = new Aspose.Pdf.Document(new MemoryStream(pdf));

var doc = new Aspose.Pdf.Document(“C:\temp\Test.pdf”);

var images = new List<Image>();

for (int pageCount = 1; pageCount <= doc.Pages.Count; pageCount++) {

using (FileStream imageStream = new FileStream(“c:\temp\image” + pageCount + “.jpg”,FileMode.Create))

{

//Width, Height, Resolution, Quality

//Quality [0-100], 100 is Maximum

var resolution = new Aspose.Pdf.Devices.Resolution(300);

[//Aspose.Pdf.Devices.JpegDevice](https://aspose.pdf.devices.jpegdevice/) jpegDevice = new Aspose.Pdf.Devices.JpegDevice(500, 700, resolution, 100);

Aspose.Pdf.Devices.JpegDevice jpegDevice = newAspose.Pdf.Devices.JpegDevice(resolution, 100);

[//Aspose.Pdf.Devices.TiffSettings](https://aspose.pdf.devices.tiffsettings/) tiffSettings = new Aspose.Pdf.Devices.TiffSettings();

[//Aspose.Pdf.Devices.TiffDevice](https://aspose.pdf.devices.tiffdevice/) tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);

[//tiffDevice.Process](https://tiffdevice.process/)(doc, imageStream);

jpegDevice.Process(doc.Pages[pageCount], imageStream);

}

}

Hi James,


Thanks for your inquiry. The issue arises when license file is expired or not implemented properly, scenario is working fine at our end with valid license implementation. Can you please double check your license file and it’s implementation? Please also check licensing documentation for reference.

If issue persist then please share a console project and your license as suggested here for further investigation.

We are sorry for the inconvenience caused.

Best Regards,