We are using PDF.Net using .net core for adding Stamps and coversheet also merging . Some time we may get corrupted files . How to identify the file is corrupted before starting any other processes
thanks
We are using PDF.Net using .net core for adding Stamps and coversheet also merging . Some time we may get corrupted files . How to identify the file is corrupted before starting any other processes
thanks
You can check whether the source input is a valid PDF file or not by using IsPdfFile property as in the code sample below.
PdfFileInfo info = new PdfFileInfo(dataDir + "input.pdf");
if (info.IsPdfFile)
{
Console.WriteLine("Valid PDF file");
}
else
{
Console.WriteLine("Invalid PDF file");
}
You can use PdfFileEditor.CorruptedItems property to get encountered problems when concatenation is performed. Following code example shows how to use this property.
PdfFileEditor pfe = new PdfFileEditor();
pfe.CorruptedFileAction = PdfFileEditor.ConcatenateCorruptedFileAction.ConcatenateIgnoringCorrupted;
if (pfe.CorruptedItems.Length > 0)
{
foreach (PdfFileEditor.CorruptedItem item in pfe.CorruptedItems)
{
Console.WriteLine(item.Index + " reason: " + item.Exception);
}
}
Thanks it is working