I am working with transformation of PDF documents into images (jpeg) and I am using GhostScript for this purpose. I work mostly with smaller documents (up to 12 pages) but when I am converting PDFs to images it takes more than 3-7 seconds to do so. Is there any way of how to speed up the GhostScriptNet (C#, ASP.NET)?
This is how I use it right now, works, but quite slowly.
using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer())
{
using (Stream attachmentStream = new MemoryStream(fileData))
{
rasterizer.Open(attachmentStream, version, true);
var startPage = GetPage(specificPage, 1);
var endPage = GetPage(specificPage, rasterizer.PageCount);
for (int i = startPage; i <= endPage; i++)
{
using (MemoryStream ms = new MemoryStream())
{
var img = rasterizer.GetPage(120, 120, i);
img.Save(ms, ImageFormat.Jpeg);
resultImageBase64.Add("data:image/jpeg;base64," + Convert.ToBase64String((byte[])ms.ToArray()));
}
}
}
rasterizer.Dispose();
}
I further tried to set different Custom switches, but this didn't do the trick either
rasterizer.CustomSwitches = new List<string>()
{
"-dMaxBitmap=500000000",
"-dNumRenderingThreads=24",
"-dBufferSpace=500000000",
"-dBGPrint=false",
"-dNOPAUSE",
"-dNOPROMPT",
"-r120", //120dpi
"-dAlignToPixels=0",
"-dGridFitTT=0",
"-dBATCH",
"-dNOEPS",
};