我使用 iTextSharp 来阅读 pdf 文件。我可以阅读英文文本,但对于中文我得到问号,我如何使用 iTextSharp 阅读中文字符。
coverNoteFilePath = @"D:\Temp\cc8a12e6-399a-4146-81ac-e49eb67e7e1b\CoverNote.pdf";
try
{
PdfReader reader = new PdfReader(coverNoteFilePath);
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)));
coverNoteContent = coverNoteContent + s;
}
reader.Close();
Response.Write(coverNoteContent);
}