Closed NvVijayakumara closed 3 years ago
You should not use Parallel to process different PDF pages for single PDF file. For instance, to get the last page from PDF, Ghostscript needs to read all pages before that page to get correct drawing state for the last page...
Hi, when I use GhostScript.NET inside Task Parallel Library (TPL) as in below example, not getting desired output. Every time when I run the app, instead of giving me correct image for corresponding page, it gives me some other page image. But when i use same code inside for or foreach loop, it works fine.
I need suggestions to get valid images for corresponding pages..
var pageCount = 0;
string inputFile = @"D:\vijay\input\test.pdf";
string outputFolder = @"D:\vijay\output\";
var xDpi = 300; //set the x DPI
var yDpi = 300; //set the y DPI
string binPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string gsDllPath = Path.Combine(binPath, Environment.Is64BitProcess ? "gsdll64.dll" : "gsdll32.dll");
using (var rasterizer = new GhostscriptRasterizer()) //create an instance for GhostscriptRasterizer
{
rasterizer.Open(inputFile, new GhostscriptVersionInfo(gsDllPath), true); //opens the PDF file for rasterizing
pageCount = rasterizer.PageCount;
}