Hello friends,
In My Windows Forms, I use PDF files with 1 MB, 20 MB, 50 MB, 100 MB... But, in the middle of processing i got the OutOfMemoryException.
The Computer Memory growing... :/
Run the same code on Console Application works very well and memory not growing.
My Code below.
In My Windows Forms, I use PDF files with 1 MB, 20 MB, 50 MB, 100 MB... But, in the middle of processing i got the OutOfMemoryException.
The Computer Memory growing... :/
Run the same code on Console Application works very well and memory not growing.
My Code below.
public void Start(string file, string outputPath, int dpi)
{
var DLL = AppDomain.CurrentDomain.BaseDirectory + "gsdll32.dll";
var gvi = new GhostscriptVersionInfo(DLL);
var proc = new GhostscriptProcessor(gvi);
var rasterizer = new GhostscriptRasterizer();
using (rasterizer = new GhostscriptRasterizer())
{
rasterizer.Open(file, gvi, true);
for (int i = 1; i <= rasterizer.PageCount; i++)
{
string pageFilePath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(file) + "-p" + i.ToString() + ".jpg");
Image img = rasterizer.GetPage(dpi, dpi, i);
img.Save(pageFilePath, ImageFormat.Jpeg);
Console.WriteLine(pageFilePath);
}
}
}
Click Button on Windows Forms MyClass.Start(openFileDialog1.FileName, docs.Diretorio, 100);