VintaSoft Imaging .NET SDK and Plug-ins Discussions
Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.
Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions
TiffPageCollection pgs = tFile.Pages;
if (pgs.Count == 0)
{
logWriter.WriteLine("-> No pages in multi-tiff. Done.");
logWriter.Close();
if (tFile != null)
tFile.Dispose();
return;
}
VintasoftImage img = new VintasoftImage(pgs[0].GetImage());
ImageCollection col = new ImageCollection(); // will hold collection of processed TIFFs
PdfEncoder pdf = new PdfEncoder(true, 80);
int pgIdx = 0;
int pdfIdx = 1;
float blankThreshold = float.Parse(ConfigurationSettings.AppSettings["blankThreshold"]);
string aPath = "";
// begin processing
foreach (TiffPage pg in pgs)
{
try
{
img.SetImage(pg.GetImage());
}
catch (Exception err)
{
logWriter.WriteLine(err);
logWriter.Close();
if (tFile != null)
tFile.Dispose();
return;
}
if (img.IsBlank(blankThreshold))
{ // cut it up
logWriter.WriteLine("-> Blank page at position: " + pgIdx);
if (col.Count > 0)
{ // save it if there meat in the collection
aPath = e.FullPath.Replace(".", "_") + "_" + pdfIdx + ".pdf";
logWriter.WriteLine("-> Creating PDF with " + col.Count + " pages.");
col.Save(aPath, pdf);
col.Clear();
logWriter.WriteLine("-> PDF saved at: " + aPath);
}
pdfIdx++;
}
else
{ // process, clean and add
img.Deskew(BorderColor.AutoDetect, 5, 5);
//img.Despeckle(8, 25, 30, 400);
col.Add(img);
}
pgIdx++;
}