Hello everyone and thanks for the help in advance. I am using GhostScript.Net to convert Pdf files to Png images. This has worked perfectly fine using Visual Studio 2019. However, when I moved to VS 2022, Here is my code:
using (var rasterizer = new GhostscriptRasterizer()) //create an instance for GhostscriptRasterizer
{
string fileName = Path.GetFileNameWithoutExtension(inputFile);
rasterizer.Open(inputFile); //opens the PDF file for rasterizing
SendEmail sendEmail9 = new SendEmail("Page Count", rasterizer.PageCount.ToString(), "");
//set the output image(png's) complete path
var outputPNGPath = @"E:\out.png";
//converts the PDF pages to png's
var pdf2PNG = rasterizer.GetPage(100, 1);
//save the png's
pdf2PNG.Save(outputPNGPath, ImageFormat.Png);
}
When attempting to save, I receive an error message "System.NullReferenceException: Object reference not set to an instance of an object". I have also tried the GhostScript.Net Fork without success. Any help would be appreciated.
i am having the same issue. Seems like the rasterizer.GetPage(100,1) returns null. Weird thing is if you do execute it again you will have a result (for me however its just a blank white page)
EDIT: Found the solution! There seems to be an updated Interpreter with latest Ghostscript versions. Add
right below your using. This uses the old interpreter.
Kudos to this guy: cannot convert pdf page to image