How to read contents of specific page from PDF using itextsharp APIs

删除回忆录丶 提交于 2019-12-23 16:05:44

问题


How to read contents of specific page from PDF using itextsharp APIs

Can anybody redirect me to the correct direction?

Thanks in advance!


回答1:


The following code only extracts text, if that is what you are looking for.

PdfReader pdfReader = new PdfReader(documentPath);

ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();

//Extract text from the page.
string txt = PdfTextExtractor.GetTextFromPage(pdfReader, page, its);

// Convert the extracted text into a readable string using the right encoding.
extractedText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(txt)));


来源:https://stackoverflow.com/questions/3421766/how-to-read-contents-of-specific-page-from-pdf-using-itextsharp-apis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!