Stack Overflow error occuring on processing PDF to TIF. See attached file and code. Please note that this error is escaping the catch being used.
static bool SavePdfFile(string oldName)
{
bool saveStatus;
var newName = oldName.Replace("Inbox", "Batch");
var newFileInfo = new FileInfo(newName);
newName = newName.Replace(newFileInfo.Extension, "_pgnum.tif");
try
{
var savePdfDocument = new Aspose.Pdf.Document(oldName);
var resolution = new Resolution(200);
var tiffSettings = new TiffSettings
{
Compression = CompressionType.CCITT4,
Depth = ColorDepth.Default,
Shape = ShapeType.None,
SkipBlankPages = true
};
var tiffDevice = new TiffDevice(resolution, tiffSettings);
var pages = savePdfDocument.Pages;
var pgCount = pages.Count;
for (int pg = 1; pg < pgCount + 1; pg++)
{
var saveName = newName.Replace("_pgnum", "_" + pg.ToString("00"));
tiffDevice.Process(savePdfDocument, pg, pg, saveName);
}
savePdfDocument.Dispose();
saveStatus = true;
}
catch (Exception exc)
{
Console.WriteLine("Exception converting PDF Doc to TIF - {0}", exc.Message);
Log.Error(oldName, "Exception converting PDF Doc to TIF", exc.Message);
saveStatus = false;
}
GC.Collect();
return saveStatus;
}