An error occured when call to 'gsapi_new_instance' is made
Posted: 25 Apr 2019, 07:50
I am trying to use GhostscriptRasterizer to create image of PDF files uploaded.
For this I am making my code async to avoid delay to enduser and complete the fileupload and image generation using threadpool. But this is only working if I am uploading single file.
When ever I try to upload more than one PDF file it gives me error in the method call "rasterizer.Open(input, version, false);"
And the error message displayed is
1. "An error occured when call to 'gsapi_new_instance' is made: -100".
2. Delegate of an exported function couldn't be created for symbol 'gsapi_revision' (Error in different machine)
I have provided the code I am using below and I am using 32bit dll.
Please provide me immediate solution for this. And if GhostscriptRasterizer supports multithreading?
Codeset
private void PdfToImage(string input, string imgFolderPath, int dpi)
{
var path = AssemblyDirectory;
Ghostscript.NET.Rasterizer.GhostscriptRasterizer rasterizer;
var version = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\gsdll32.dll", string.Empty, GhostscriptLicense.GPL);
using (rasterizer = new Ghostscript.NET.Rasterizer.GhostscriptRasterizer())
{
rasterizer.Open(input, version, false);
var pageFilePath = Path.Combine(imgFolderPath, string.Concat(Path.GetFileNameWithoutExtension(input), ".jpg"));
var img = rasterizer.GetPage(dpi, dpi, 1);
img.Save(pageFilePath, ImageFormat.Jpeg);
rasterizer.Close();
}
}
For this I am making my code async to avoid delay to enduser and complete the fileupload and image generation using threadpool. But this is only working if I am uploading single file.
When ever I try to upload more than one PDF file it gives me error in the method call "rasterizer.Open(input, version, false);"
And the error message displayed is
1. "An error occured when call to 'gsapi_new_instance' is made: -100".
2. Delegate of an exported function couldn't be created for symbol 'gsapi_revision' (Error in different machine)
I have provided the code I am using below and I am using 32bit dll.
Please provide me immediate solution for this. And if GhostscriptRasterizer supports multithreading?
Codeset
private void PdfToImage(string input, string imgFolderPath, int dpi)
{
var path = AssemblyDirectory;
Ghostscript.NET.Rasterizer.GhostscriptRasterizer rasterizer;
var version = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\gsdll32.dll", string.Empty, GhostscriptLicense.GPL);
using (rasterizer = new Ghostscript.NET.Rasterizer.GhostscriptRasterizer())
{
rasterizer.Open(input, version, false);
var pageFilePath = Path.Combine(imgFolderPath, string.Concat(Path.GetFileNameWithoutExtension(input), ".jpg"));
var img = rasterizer.GetPage(dpi, dpi, 1);
img.Save(pageFilePath, ImageFormat.Jpeg);
rasterizer.Close();
}
}