Dear support,
I’m using Aspose.PDF to get thumbnail of first page of some pdf files with below code, but error occurred:
“Object reference not set to an instance of an object”
using (var ms = new MemoryStream(File.ReadAllBytes(@“D:\Beginning Microsoft SQL Server 2012 Programming.pdf”)))
{
var pdf = new Document(ms);
var mso = pdf.ConvertPageToPNGMemoryStream(pdf.Pages[1]);
File.WriteAllBytes(@“D:\Beginning Microsoft SQL Server 2012 Programming.pdf.png”, mso.ToArray());
}
Stack Trace:
at #=zUCCFEnc8iGlSEATxRvUz6XuQYphwTZyXRAgWRKP9wuNT.#=zMoUFucUnkZ2S(#=zMpjOs7VDXIsCbHv8UdtR4Z_sSQ82Ath1HQ== #=zfvoEoF8=, #=zK0Zae2nT9grrdestLRwNBCgRmpsSL8R2ORSIRuKbDFtA #=zmrHx47E=, #=zZINVwcFDY7TE1hiyb97c7HX$$vd9UIckWw== #=z3ObmjWQZ_2mF)
at #=zUCCFEnc8iGlSEATxRvUz6XuQYphwTZyXRAgWRKP9wuNT.#=z1S1kheEOQ7Sy(#=zMpjOs7VDXIsCbHv8UdtR4Z_sSQ82Ath1HQ== #=zfvoEoF8=, #=zK0Zae2nT9grrdestLRwNBCgRmpsSL8R2ORSIRuKbDFtA #=zmrHx47E=)
at #=zUCCFEnc8iGlSEATxRvUz6XuQYphwTZyXRAgWRKP9wuNT.#=zK7XUQHA=(#=zscDifpOod22ZYH6qMuyxduz5bGkL #=z4E3QaJI=, #=zMpjOs7VDXIsCbHv8UdtR4Z_sSQ82Ath1HQ== #=zfvoEoF8=, #=z63qwDDCy8HEFsxbAMBNU3QSn4LfVZKFLeDUiKCY= #=zllCT5Zg=, #=zK0Zae2nT9grrdestLRwNBCgRmpsSL8R2ORSIRuKbDFtA& #=zmrHx47E=)
at #=zPVWVjCyah_TMHUWViTXz62LTIxew.#=zhBRLJYE=(#=zK0Zae2nT9grrdestLRwNBCgRmpsSL8R2ORSIRuKbDFtA& #=zmrHx47E=)
at Aspose.Pdf.Devices.ImageDevice.#=zhBRLJYE=(Page #=zfvoEoF8=)
at Aspose.Pdf.Devices.PngDevice.Process(Page page, Stream output)
at Aspose.Pdf.Facades.PdfConverter.#=zchpYpsNHqlJd4fk2Nw==(Page #=zfvoEoF8=)
at ConsoleApp1.PdfUtilities.TakeSnapshot(Document pdf) in C:\Users\milad\source\repos\ConsoleApp1\ConsoleApp1\PdfUtilities.cs:line 54
at ConsoleApp1.Program.Main(String[] args) in C:\Users\milad\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 33
Thank you and best regards
Milad Ashrafi