25-02-20 02:29 PM
using iTextSharp, also the
using iTextSharp.text.pdf.parser; is not used anymore so this code wouldn't work anymore.
using iTextSharp.text.pdf; using iTextSharp.text.pdf.parser; using System.IO; public string ReadPdfFile(string fileName) { StringBuilder text = new StringBuilder(); if (File.Exists(fileName)) { PdfReader pdfReader = new PdfReader(fileName); for (int page = 1; page <= pdfReader.NumberOfPages; page++) { ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); text.Append(currentText); } pdfReader.Close(); } return text.ToString(); }
Thank you in advance~!
Answered! Go to Answer.
26-02-20 11:22 AM
26-02-20 05:37 AM
26-02-20 10:54 AM
26-02-20 11:22 AM
26-02-20 12:03 PM
26-02-20 12:10 PM
26-02-20 12:15 PM
26-02-20 12:23 PM