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

pdftk error: Unexpected Exception in open_reader() #21

Open
shivams opened this issue May 1, 2015 · 3 comments
Open

pdftk error: Unexpected Exception in open_reader() #21

shivams opened this issue May 1, 2015 · 3 comments

Comments

@shivams
Copy link

shivams commented May 1, 2015

For some PDF files, pdftk throws this error:

Error: Unexpected Exception in open_reader()
Unhandled Java Exception:

This bug has been reported on pdftk launchpad: https://bugs.launchpad.net/ubuntu/+source/pdftk/+bug/774052

It seems like the bug hasn't been fixed. Due to this bug, pdfocr.rb also fails on many occasions. However, there is a temporary solution that I have. The solution is something like this:

Sometimes, pdftk completely fails to read certain types of PDFs. However, if we read those PDFs using some other tool and then recreate them, then pdftk will read the newly created PDF just fine. E.g. we can use ghostscript to recreate pdf like this:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=newfile.pdf myfile.pdf

Now pdftk will read the newly created PDF file just fine.

If someone is willing to apply this solution, then it'd be really good. Otherwise I will make the changes myself and send a pull request.

PS:
A sample file which fails to be read is given here: https://www.jstage.jst.go.jp/article/jsmec/45/3/45_3_730/_pdf

@mcdlee
Copy link

mcdlee commented Aug 17, 2015

I met similar error under Windows environment if the path of PDF file contained "Non-Latin characters", such as Chinese. But if I move the PDF file to the path without Chinese, it works.

@ahmad-elkomey
Copy link

I met similar error under Windows environment if the path of PDF file contained "Non-Latin characters", such as Chinese. But if I move the PDF file to the path without Chinese, it works.

Thanks! That is a very useful comment. The path I had problem with had whitespace. I moved the files some other path that doesn't have whitespace.

@mkyildiz01
Copy link

I met similar error under Windows environment if the path of PDF file contained "Non-Latin characters", such as Chinese. But if I move the PDF file to the path without Chinese, it works.

When I changed the path, I could also combine my files. Thank you!

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