From 02cc54be1990c77e960e01d7c5f6a9242f3dbf9b Mon Sep 17 00:00:00 2001 From: Gowtham Karthikeyan <30730201+inboxsgk@users.noreply.github.com> Date: Wed, 6 Apr 2022 11:16:15 +0530 Subject: [PATCH] BUG: Add whitespace between words for extractText() (#569) Previously the function .extractText() reads the text in the PDF and returns without any spaces. In this fix the pdf.py file has been modified to add " " (space) in between two words Here is an example below:- Original Sentence : "The quick brown fox jumps over the lazy dog" Previous Output : "Thequickbrownfoxjumpsoverthelazydog" After the fix : "The quick brown fox jumps over the lazy dog" --- PyPDF2/pdf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index d278a874e..ec2cf1f0b 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -2683,6 +2683,7 @@ def extractText(self): elif operator == b_("TJ"): for i in operands[0]: if isinstance(i, TextStringObject): + text += " " text += i text += "\n" return text