diff --git a/pdfminer/pdfdevice.py b/pdfminer/pdfdevice.py index 2374601c..184922f9 100644 --- a/pdfminer/pdfdevice.py +++ b/pdfminer/pdfdevice.py @@ -167,7 +167,7 @@ def render_string_horizontal( if isinstance(obj, (int, float)): x -= obj * dxscale needcharspace = True - else: + elif isinstance(obj, bytes): for cid in font.decode(obj): if needcharspace: x += charspace @@ -207,7 +207,7 @@ def render_string_vertical( if isinstance(obj, (int, float)): y -= obj * dxscale needcharspace = True - else: + elif isinstance(obj, bytes): for cid in font.decode(obj): if needcharspace: y += charspace diff --git a/samples/contrib/issue-1059-cmap-decode.pdf b/samples/contrib/issue-1059-cmap-decode.pdf new file mode 100644 index 00000000..452973df Binary files /dev/null and b/samples/contrib/issue-1059-cmap-decode.pdf differ diff --git a/tests/test_tools_pdf2txt.py b/tests/test_tools_pdf2txt.py index e80a5e69..e1ae7a01 100644 --- a/tests/test_tools_pdf2txt.py +++ b/tests/test_tools_pdf2txt.py @@ -68,6 +68,12 @@ def test_contrib_issue_350(self): """ run("contrib/issue-00352-asw-oct96-p41.pdf") + def test_contrib_issue_1059_textseq(self): + """Ensure that CMaps are robust to non-strings in text + sequences + (https://github.com/pdfminer/pdfminer.six/issues/1059).""" + run("contrib/issue-1059-cmap-decode.pdf") + def test_scancode_patchelf(self): """Regression test for https://github.com/euske/pdfminer/issues/96""" run("scancode/patchelf.pdf")