black square box while generating pdf (unicode error)
See original GitHub issueA weird problem. While generating pdf, inplace of unicodes square black boxes apperars. Dont know if its unicode or font-face error. I even dont know if to use the “font-face and font-family” to generate the unicode into pdf. Anything I am missing ?? Great thanks.
Code snippet # -- coding: utf-8 --
from xhtml2pdf import pisa
from StringIO import StringIO
source = """<html>
<style>
@font-face {
font-family: Mangal;
src: url("mangal.ttf");
}
body {
font-family: Mangal;
}
</style>
<body>
This is a test <br/>
सरल
</body>
</html>"""
# Utility function
def convertHtmlToPdf(source):
pdf = StringIO()
pisaStatus = pisa.CreatePDF(StringIO(source.encode('utf-8')), pdf)
# return True on success and False on errors
print "Success: ", pisaStatus.err
return pdf
# Main program
if __name__=="__main__":
print pisa.showLogging()
pdf = convertHtmlToPdf(source)
fd = open("test.pdf", "w+b")
fd.write(pdf.getvalue())
fd.close()
Issue Analytics
- State:
- Created 10 years ago
- Comments:31 (2 by maintainers)
Top Results From Across the Web
trouble in converting unicode template to pdf using xhtml2pdf
But while converting it into html using xhtml2pdf, it generating black, solid square boxes in the unicodes.
Read more >What symbol is the square box shown for non-representable ...
U+FFFD REPLACEMENT CHARACTER, , is used to signal errors in invalid Unicode streams; it's usually rendered as a question mark inside a...
Read more >Mouse pointer changes into a black box when moved over ...
If your mouse cursor changes into a black box when moved over blank areas in a PDF document, use the solution below as...
Read more >When I print to Adobe PDF, strange symbols appear in the ...
Lookfor IMAGE COLOR MANAGEMENT, TRUE TYPE FONT: Clickon the “Substitute with device font.” A dropdown box will appear. Click on “DOWNLOAD AS SOFTFONT.”....
Read more >Why does Notepad++ display some Unicode characters as ...
It can display ₐ₊₋ but some other subscripts (like ₂ₙ ) are converted to squares. When I copy that square and paste on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s very disappoiting to add local fonts for any HTML document to render in non-latin encoding
yes it’s work but if you put some russian chars, it creates black squares the problem is how we can use non english chars?