Reputation: 3358
I know this kind of question has been asked before but nothing worked for me.
I'm trying to generate some PDF report using weasyprint
. Here is my code;
htmlContent = py_str["htmlContent"]
HTML(string=htmlContent).write_pdf(target=response,
stylesheets=[CSS(string=getCSS())])
but it doesn't generate any PDF. On debugging I found out that issue is in this getCSS()
function that returns css string. By print this funtion on console, I'm getting this error
UnicodeEncodeError: 'charmap' codec can't encode character '\x91' in position 5042: character maps to <undefined>
this is CSS that I've from line number 5040 to 5042
.nav-pills > li {
float: left;
}
All solutions that I found out are related to utf-8
but I could not understand where to use this utf-8
in my code. I'm totally stuck here.
Any kind of help will be appreciated. I can add full css if needed.
UPDATE
I've tried using encoding("utf-8") in these ways;
HTML(string=htmlContent).write_pdf(target=response,
stylesheets=[CSS(string=getCSS().encode("utf-8"))])
and then this one too
HTML(string=htmlContent, encoding="utf-8").write_pdf(target=response,
stylesheets=[CSS(string=getCSS())])
But no luck...
Upvotes: 0
Views: 374
Reputation: 3358
Anyone who is facing this issue and nothing worked for you like me.. try disabling your extensions/ add-Ons of browsers. In my case, I've to uninstall IDM and my issue is gone. Now I need to find why it is not working with IDM. But for time being, my issue is resolved.
Upvotes: 0