There are garbled characters and some text, which can be copied inside a viewer, can not be found in the exctract_text()
Environment
$ python -m platform
Windows-10-10.0.22000-SP0
$ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.6.0
Code + PDF
This is a minimal, complete example that shows the issue (with #1136 to fix keyerror "\W"):
import os
import PyPDF2
pdf_filename="ST辅仁:2019年年度报告.PDF"
txt_filename="ST辅仁:2019年年度报告.txt"
with open(pdf_filename, 'rb') as pdfFileObj:
pdfReader = PyPDF2.PdfReader(pdfFileObj)
x=pdfReader.numPages
with open(txt_filename,"a",encoding='utf-16') as file1:
for i in range(x):
pageobj=pdfReader.pages[i]
text=pageobj.extract_text()
file1.writelines(text)
ST辅仁:2019年年度报告.PDF
Original PDF snippets
page 7/254:

copied from pdf file: 第二季度
TXT file finder

The txt editor told that there is no "第二季度" inside the txt file.
Notice that it's only one example in this PDF file.
Example of garbled characters
�]
-Añ-��J �7 �]
-Añ�h1Ñ*6��
ˆ�J
�:�Ô�p �7 �:#§Añ�h�Ô�C�p
�\ œ
(�à œ
( �7 Eµ�ñ9Ÿ�JLö
��f9Ÿ6Ñ�-�9L€ œ
(
Eµ�ñ�2 �7 "ã ‡Eµ�ñ�2�f9Ÿ�9L€ œ
(
Eµ�ñLö
� �7 Eµ�ñ9Ÿ�JLö
��9L€ œ
(
�09ŸLö
� �7 �0�1�f9Ÿ�ÄLö
��Å�9L€ œ
(
�»"ãG‚�J �7 "ã ‡-1�»"ãG‚�J6Ñ�-�9L€ œ
here is the txt extracted:
ST辅仁:2019年年度报告.txt
There are garbled characters and some text, which can be copied inside a viewer, can not be found in the
exctract_text()Environment
$ python -m platform Windows-10-10.0.22000-SP0 $ python -c "import PyPDF2;print(PyPDF2.__version__)" 2.6.0Code + PDF
This is a minimal, complete example that shows the issue (with #1136 to fix keyerror "\W"):
ST辅仁:2019年年度报告.PDF
Original PDF snippets
page 7/254:

copied from pdf file: 第二季度
TXT file finder

The txt editor told that there is no "第二季度" inside the txt file. Notice that it's only one example in this PDF file.Example of garbled characters
�]
-Añ-��J �7 �]
-Añ�h1Ñ*6��
ˆ�J
�:�Ô�p �7 �:#§Añ�h�Ô�C�p
�\ œ
(�à œ
( �7 Eµ�ñ9Ÿ�JLö
��f9Ÿ6Ñ�-�9L€ œ
(
Eµ�ñ�2 �7 "ã ‡Eµ�ñ�2�f9Ÿ�9L€ œ
(
Eµ�ñLö
� �7 Eµ�ñ9Ÿ�JLö
��9L€ œ
(
�09ŸLö
� �7 �0�1�f9Ÿ�ÄLö
��Å�9L€ œ
(
�»"ãG‚�J �7 "ã ‡-1�»"ãG‚�J6Ñ�-�9L€ œ
here is the txt extracted:
ST辅仁:2019年年度报告.txt