I'm trying to read text in a PDF doc using itextsharp library. I have a problem with a particular doc that only returns ? character. However with others doc I have not any problem.
¿What is the reason for that?
Here is my code
private void readPDF()
{
string pdfTemplate = @"c:\\test2.pdf";
// Título de formulario
this.Text += " - " + pdfTemplate;
String strText="";
try
{
PdfReader reader = new PdfReader(pdfTemplate);
for (int page = 1; page <= reader.NumberOfPages; page++)
{
ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
String s = PdfTextExtractor.GetTextFromPage(reader, page, its);
s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
strText = strText + s;
}
reader.Close();
textBox1.Text = strText;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Any ideas?? Thanks