Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot convert 'PSKeyword' object to bytearray #1048

Open
Aegdesil opened this issue Oct 7, 2024 · 0 comments
Open

cannot convert 'PSKeyword' object to bytearray #1048

Aegdesil opened this issue Oct 7, 2024 · 0 comments

Comments

@Aegdesil
Copy link

Aegdesil commented Oct 7, 2024

I am having this error while loading a specific PDF with pdfplumber.
I cannot share this PDF as it contains sensitive information, however I can provide more debug information if needed.

The PDF is a one page PDF, extracted from a larger PDF using pypdf and then saved as a new PDF file.
Note that the large PDF does get parsed fine with pdfplumber, it is only the single page extracted with pyPDF that crashes.
When viewed in a PDF reader app, the page does however appear partially unrendered in the large document, so the document may be invalid from the start.
The code works fine for all other PDFs I tested.

This is the stack trace, the error comes from the PDFFont.decode method

pdfminer/pdffont.py in decode at line 901
pdfminer/pdfdevice.py in render_string_horizontal at line 170
pdfminer/pdfdevice.py in render_string at line 133
pdfminer/pdfinterp.py in do_TJ at line 902
pdfminer/pdfinterp.py in execute at line 1042
pdfminer/pdfinterp.py in render_contents at line 1016
pdfminer/pdfinterp.py in process_page at line 997
pdfplumber/page.py in layout at line 277

The seq argument in the PDFDevice.render_string_horizontal method contains only bytestrings, except the last element which is a PSKeyword b')' that creates the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Aegdesil and others