-
Notifications
You must be signed in to change notification settings - Fork 646
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
Encoding Error #893
Comments
Does monkeypatching class WickedPdf
module WickedPdfHelper
module Assets
private
def read_from_uri(uri)
asset = Net::HTTP.get(URI(uri))
asset.force_encoding('UTF-8') if asset # <- new line added
asset = gzip(asset) if WickedPdf.config[:expect_gzipped_remote_assets]
asset
end
end
end
end |
Yes that fixes it. I had tried similar in a branch I created https://github.com/mikem836/wicked_pdf/tree/encoding but wasn't confident enough in the general applicability of the fix to do a PR. |
Sweet. Would you mind making a PR with this change and a related note in the CHANGELOG? |
Will do. I did want to add a test also, but haven't been able to get the tests running locally. |
What kind of issue are you running into running the tests? |
Yes, I created the PR and everything ran on TravisCI. I just haven't been able to run them locally. I think some kind of path issue in my local environment. |
Issue description
With version 2.0.1, when I try to render a PDF that has any UTF characters, I get the error from Rails: Encoding::CompatibilityError "incompatible character encodings: ASCII-8BIT and UTF-8" It appears that PR #864 removed UTF-8 encoding when changed from using open-uri to net/http.
Expected or desired behavior
No error. The same PDF can be rendered without error on wicked_pdf 2.0.0
System specifications
wicked_pdf gem version (output of
cat Gemfile.lock | grep wicked_pdf
): 2.0.1wkhtmltopdf version (output of
wkhtmltopdf --version
): 0.12.5whtmltopdf provider gem and version if one is used: tested both wkhtmltopdf-binary-edge v0.12.5.1 and wkhtmltopdf-heroku v2.12.5.0
platform/distribution and version (e.g. Windows 10 / Ubuntu 16.04 / Heroku cedar): Heroku 18
The text was updated successfully, but these errors were encountered: