How to read specific page content from PDF using itextsharp API

How to read the contents of a specific page from a PDF using the itextsharp API

Can someone redirect me in the right direction?

Thanks in advance!

+3
source share
1 answer

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)));
+1
source

Source: https://habr.com/ru/post/1758338/


All Articles