Comments (8)
How does your HTML code start out? mine starts out like:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
and it works fine for me with Chinese in it... Also using 1.8.7 (non-EE) If you were missing the content-type...charset=utf-8 meta tag, I'd imagine it behaving like you describe (since this is how Safari behaves without it too).
from pdfkit.
Hmmm... thanks. Adding the meta tag seems to have resolved the problem. I'd not checked for that as the HTTP headers were already returning "text/html; charset=utf-8", but maybe the way pdfkit passes the data through doesn't preserve that? Seems worth a mention in the docs?
from pdfkit.
The underlying implementation is the wkhtmltopdf command line tool. For those who are generating or loading it internally, instead of pulling it from a remote source, there are no HTTP headers to confuse anyone on this point anyway. It could be possible I suppose to pass wkhtmltopdf remote HTTP headers when it's being pulled from an external HTTP source...
from pdfkit.
Right, I understand that now, though it is initially confusing that when I made the request using the command line tool directly it handled the utf8 content just fine (which turns out to be because my command line usage was causing wkhtmltopdf to work over http, whereas pdfkit hands it a string)
That's all fine, and makes sense. At this point I'm simply suggesting that it would be sensible to add a note about this to the docs as for those of us primarily used to working with http and browsers it's not immediately apparent that the http headers have no effect here.
from pdfkit.
In case this helps anyone else, I was having an issue, even with the doctype and html. What helped was changing my code to this:
import codecs
import pdfkit
input_filename = 'input.html'
output_filename = 'output.pdf'
with codecs.open(input_filename, "r", "utf-8") as f:
html_text = f.read()
pdfkit.from_string(html_text, output_filename)
from pdfkit.
@jessamynsmith this is the Ruby pdfkit project :)
from pdfkit.
Oops. Well, the doctype and html stuff still helped me. :)
from pdfkit.
No worries @jessamynsmith :)
from pdfkit.
Related Issues (20)
- How to decrease response time for loading the page for image ? HOT 1
- File.exists? is deprecated HOT 2
- URI::escape and URI::decode are deprecated in Ruby 3 HOT 4
- bug: DPI settings generate wrong command? HOT 1
- Command Injection in pdfkit >=0.0.0 (CVE-2022-25765) HOT 1
- empty pdf file generating
- Vulnerabilities found! HOT 3
- Changes in #511 break PDFKit for rack 2.x apps HOT 1
- High Severity: URL Escaping when you should be shell escaping HOT 12
- Support for multiple `replace` HOT 3
- Support for multiple `replace` HOT 1
- wkhtmltopdf is deprecated by its author HOT 2
- Exit with code 1 due to network error: ProtocolUnknownError HOT 5
- Should latest commit not be released as 0.8.7.3? HOT 1
- Error when trying to convert to pdf HOT 3
- AmCharts Graphs Not Rendering in PDF Using pdfkit HOT 1
- convert pdf to html HOT 1
- PR Bot Configuration HOT 1
- PDF/A-1 HOT 1
- Table can not be recovered HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfkit.