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

Fix encoding for pdftotext (Russian characters, German umlauts etc). Fix version in download instructions #813

Merged
merged 6 commits into from
Feb 9, 2021

Conversation

tholor
Copy link
Member

@tholor tholor commented Feb 8, 2021

Fixes #805

It seems that pdftotext uses different default encodings depending on the host machine. While on my machine all pdfs in #805 get converted correctly, the converter on a Google Colab notebook just produced gibberish.
It might be related to environment variables on the host like LC_ALL or LANG.

With this PR we are enabling users to pass a custom encoding to PDFToTextConverter.convert().

"Latin 1" is the default encoding of pdftotext. While this works well on many PDFs, it might be needed to switch to "UTF-8" or
others if your doc contains special characters (e.g. German Umlauts, Cyrillic characters ...).

Note: With "UTF-8" we experienced cases, where a simple "fi" gets wrongly parsed as "xef\xac\x81c" which is a latin small ligature (see test cases). That's why we keep "Latin 1" as the default here. (See the list of available encodings by running pdftotext -listencodings in the terminal)

Also fixing the pdftotext install instructions from 4.02 to 4.03 (thanks for the pointer @m1kol)

@tholor tholor requested a review from tanaysoni February 8, 2021 16:07
@tholor tholor self-assigned this Feb 8, 2021
@tholor tholor changed the title fix encoding of pdftotext. fix version in download instructions Fix encoding for pdftotext (Russian characters, German umlauts etc). Fix version in download instructions Feb 8, 2021
@tholor tholor merged commit ac9f924 into master Feb 9, 2021
@tholor tholor deleted the fix_pdf_encoding branch February 9, 2021 12:42
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

Successfully merging this pull request may close these issues.

PDF Converter on Russian language
2 participants