-1

I got this function of itextsharp library to extract pdf text line by line:

PdfTextExtractor.GetTextFromPage(reader, page);

...but I need to put ENTER at every line every end of line of pdf even if there is empty row it should read empty row.

2
  • 2
    PdfTextExtractor.GetTextFromPage does put end-of-line markers at the end of every line it recognizes (cf. the method GetResultantText of the LocationTextExtractionStrategy: sb.Append('\n');). That being said there generally is no end of line or row in a PDF! Therefore, if iText's heuristics for interpreting such concepts into the PDF page content don't work for you, you may need a custom TextExtractionStrategy implementation. If you need help with that, please give more details, especially what you get, what you want, and a sample PDF illustrating your issue.
    – mkl
    May 6, 2013 at 8:59
  • +1 for @mkl: There is no such thing as 'a line' in a PDF, nor is there such a thing as 'ENTER'. Content is added at absolute positions; it isn't organized in lines. May 6, 2013 at 10:18

2 Answers 2

4

read into a string variable then split e.g. String page = PdfTextExtractor.getTextFromPage(reader, 2);

String[] s1 = page.split('\n'); 
0
0

Please go through the following Links:

  1. http://api.itextpdf.com/index.html?com/itextpdf/text/pdf/parser/PdfTextExtractor.html

  2. link of stack-overflow: Itextsharp text extraction

2
  • 1
    Welcome to Stack Overflow! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – JJJ
    May 6, 2013 at 6:12
  • Concerning the stack overflow link: Please make clear that you indeed want to refer to the answers making use of the PdfTextExtractor class.
    – mkl
    May 6, 2013 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.