[Fixed]-Django / django-easy-pdf : 'NoneType' object has no attribute 'encode'

1👍

I can’t even believe I’ve spent a few days crying and tearing my hair out because I was using a Google font. Yep, once I removed <link href="http://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" type="text/css"> from my template, the error vamoosed!

0👍

After dig in xhml2pdf I saw @RMPhoenix is right the only solution (for now) is remove the CSS causing this error. The traceback clearly shows that CSS parser raise an error.

But the more relevant is I think this piece of code:

xhtml2pdf/parser.py in pisaParser at line 711:

    if default_css:
        context.addDefaultCSS(default_css)
    pisaPreLoop(document, context)
    #try:
    context.parseCSS()
    #except:
    #    context.cssText = DEFAULT_CSS
    #    context.parseCSS()
    # context.debug(9, pprint.pformat(context.css))
    pisaLoop(document, context)
👤Zulu

Leave a comment