File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ def compute_space_width(
410
410
else :
411
411
w = []
412
412
while len (w ) > 0 :
413
- st = w [0 ]
413
+ st = w [0 ] if isinstance ( w [ 0 ], int ) else w [ 0 ]. get_object ()
414
414
second = w [1 ].get_object ()
415
415
if isinstance (second , int ):
416
416
for x in range (st , second ):
Original file line number Diff line number Diff line change @@ -191,6 +191,18 @@ def test_unixxx_glyphs():
191
191
assert pat in txt
192
192
193
193
194
+ @pytest .mark .enable_socket ()
195
+ def test_cmap_compute_space_width ():
196
+ # issue 2137
197
+ # original file URL:
198
+ url = "https://arxiv.org/pdf/2005.05909.pdf"
199
+ # URL from github issue is too long to pass code stype check, use original arxiv URL instead
200
+ # url = "https://github.com/py-pdf/pypdf/files/12489914/Morris.et.al.-.2020.-.TextAttack.A.Framework.for.Adversarial.Attacks.Data.Augmentation.and.Adversarial.Training.in.NLP.pdf"
201
+ name = "TextAttack_paper.pdf"
202
+ reader = PdfReader (BytesIO (get_data_from_url (url , name = name )))
203
+ reader .pages [0 ].extract_text () # no error
204
+
205
+
194
206
@pytest .mark .enable_socket ()
195
207
def test_tabs_in_cmap ():
196
208
"""Issue #2173"""
You can’t perform that action at this time.
0 commit comments