CSS not rendered by Pisa's pdf generation in Django
问题 I generate a pdf file from HTML using Pisa: def fetch_resources(uri, rel): path = os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, "")) return path def write_pdf(template_src, context_dict, filename): template = get_template(template_src) context = Context(context_dict) html = template.render(context) result = open(filename, 'wb') pdf = pisa.pisaDocument(StringIO.StringIO( html.encode("UTF-8")), result, link_callback=fetch_resources) result.close() My HTML has a link to an