1
我的jinja2没有拿起我的样式表。Jinja2没有拿起CSS,
代码:
env = Environment(loader=FileSystemLoader('./templates/'))
template = env.get_template("report1.html")
template_vars = {"title": "Top 20", "stake_indiv": ms[0:21].to_html()}
html_out = template.render(template_vars)
# i then use the HTML to generate a PDF file but it has no stylesheet info
我没有得到呈现任何错误或创建PDF时
我的HTML是:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
<link type="text/css" rel="stylesheet" href="./templates/style.css">
</head>
<body>
<h2>Stake individuals</h2>
{{stake_indiv}}
</body>
</html>
,我已经从typography.css文件蓝图css命名为风格
没有错误,我只是不知道如何找出问题
上编辑添加PDF生成代码,这是使用PyQt4的
app = gui.QApplication(sys.argv)
web = kit.QWebView()
web.setHtml(html)
printer = gui.QPrinter()
printer.setPageSize(gui.QPrinter.A4)
printer.setOutputFormat(gui.QPrinter.PdfFormat)
printer.setOutputFileName(destination)
web.print_(printer)
app.exit()
如果您在浏览器中查看生成的HTML,会发生什么情况? – mgilson
那是一个明显的测试(对不起)。是的,它适用于样式表。 (假设HTML位于项目目录中,那么./templates/将正确指向css文件。 因此,谁没有选择样式表?我猜这是我的PDF转换器。 – cryptoref
是的,可能PDF转换器...。 – mgilson