Чтобы прочитать PDF, попробуйте использовать:
private static string ReadPdfFile(string fileName)
{
StringBuilder text = new StringBuilder();
if (File.Exists(fileName))
{
PdfReader pdfReader = new PdfReader(fileName);
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, 1, strategy);
//currentText = Encoding.UTF8.GetString(UTF8Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
text.Append(currentText);
}
return text.ToString();
}
Затем на извлеченном тексте:
public static string Arabic1256ToUtf8(string data)
{
var latin = Encoding.GetEncoding("ISO-8859-1");
var bytes = latin.GetBytes(data); // get the bytes for your ANSI string
var arabic = Encoding.GetEncoding("Windows-1256"); // decode it using the correct encoding
return arabic.GetString(bytes);
}