using System.Security.Cryptography;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
string pdfPath1 = "ruta/del/archivo1.pdf";
string pdfPath2 = "ruta/del/archivo2.pdf";
string text1 = ExtractTextFromPdf(pdfPath1);
string text2 = ExtractTextFromPdf(pdfPath2);
string hash1 = CalculateHash(text1);
string hash2 = CalculateHash(text2);
Console.WriteLine("Los archivos PDF son idénticos.");
Console.WriteLine("Los archivos PDF son diferentes.");
static string ExtractTextFromPdf(string pdfFilePath)
using (PdfReader reader = new PdfReader(pdfFilePath))
for (int page = 1; page <= reader.NumberOfPages; page++)
text += PdfTextExtractor.GetTextFromPage(reader, page);
static string CalculateHash(string input)
using (SHA256 sha256Hash = SHA256.Create())
byte[] data = sha256Hash.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input));
return BitConverter.ToString(data).Replace("-", String.Empty);