anoop gs

anoop gs

  • NA
  • 26
  • 3.9k

C# code -Compare 2 list and export the difference in excel

Mar 17 2020 2:13 AM
I have twp pdfs.I want to compare it.For that i converts 2 pdf into 2 lists.I want to compare the 2 lists and export the difference as 2 columns in excel.Could you please help me to find the  c# code for it?Please find the below incomplete code?
public static void CompareTwoPDF(string FirstPDF, string SecondPDF)
{
if (File.Exists(FirstPDF) && File.Exists(SecondPDF))
{
PdfReader reader = new PdfReader(SecondPDF);
for (int page = 1; page <= reader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
FirstFile += PdfTextExtractor.GetTextFromPage(reader, page, strategy);
}
PdfReader reader1 = new PdfReader(FirstPDF);
for (int page = 1; page <= reader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
SecondFile += PdfTextExtractor.GetTextFromPage(reader1, page, strategy);
}
}
else
{
Console.WriteLine("Files does not exist.");
}
List<string> File1diff;
List<string> File2diff;
IEnumerable<string> file1 = FirstFile.Trim().Split('\r', '\n');
IEnumerable<string> file2 = SecondFile.Trim().Split('\r', '\n');
File1diff = file1.ToList();
File2diff = file2.ToList();
}
}
}
}
 
 

Answers (5)