I have a Sharepoint application that uses the Ghostscript.net wrapper to rasterize pdf documents to png. Right now I am using the example from their site. But the issue I have is when I try to convert to pdfs at the same time. Using this code works only one at a time. But I get the error "An error occured when call to 'gsapi_new_instance' is made: -100" when I attempt to convert 2 pdf's simultaneously.
using (MemoryStream pdfStream = new MemoryStream(pdfbyte))
using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
{
rasterizer.Open(pdfStream, version, false);
for (int i = 1; i <= rasterizer.PageCount; i++)
{
using (MemoryStream ms = new MemoryStream())
{
DrawImage img = rasterizer.GetPage(dpi, dpi, i);
img.Save(ms, ImageFormat.Png);
ms.Close();
output = "data:image/png;base64," + Convert.ToBase64String((byte[])ms.ToArray());
}
}
rasterizer.Close();
Otherwise if I use rasterizer.Open(pdfStream, version, true);
I the error "Arithmetic operation resulted in an overflow"
Should I be using a GhostscriptProcessor or Viewer instance instead? Does anyone have a good example of this code?