0
我一直在使用下面的C#代码从PDF文件阅读的文本从PDF符号和文字:阅读利用iText
PdfReader reader = new PdfReader(openFileDialog1.FileName);
int n = reader.NumberOfPages;
// file properties
Dictionary<string, string> infodict = reader.Info;
string strText = string.Empty;
PdfReader reader2 = new PdfReader(openFileDialog1.FileName);
for (int page = 1; page <= n; 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();
}
MessageBox.Show(strText);
此代码无法读取PDF文件的符号。有什么办法可以从PDF文件中读取符号吗?
这是什么线?:做 S = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default,Encoding.UTF8,Encoding.Default.GetBytes的LocationTextExtractionStrategy (s))) 我会完全删除此行。 –
s读取整个页面的文本。 – fawad
s,正在转换为UTF8,然后编码为ASCII,然后回到UTF8,它如何“读取”页面? –