我正在尝试包含我的自定义字体,但出现以下错误,表明未找到该字体。但是,我可以确认我正确地指向字体目录。
OSError: wkhtmltopdf reported an error:
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==============================> ] 50%
Error: Failed to load file:///C:/Users/xxxxx/AppData/Local/Temp/cmunrm.ttf, with network status code 203 and http status code 0 - Error opening C:/Users/xxxxx/AppData/Local/Temp/cmunrm.ttf: No such file or
app.py 的代码片段
@app.route('/getDetails', methods=['POST'])
def x():
if request.method == 'POST':
path_wkhtmltopdf = 'static/wkhtmltopdf/bin/wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
rendered=render_template('resume.html',test='hi')
cssPath=['static/css/resumeCss.css']
pdf=pdfkit.from_string(rendered, False,configuration=config,css=cssPath)
response=make_response(pdf)
response.headers['Content-Type']='application/pdf'
# response.headers['Content-Disposition']='attachment; filename=Print Me.pdf'
response.headers['Content-Disposition']='inline'
return response
简历CSS.css
@font-face {
font-family: myFirstFont;
src: url('../fonts/cmunrm.ttf');
}
h1{
font-family: myFirstFont;
}
我还浏览了 wkhtmltopdf 的文档并查看了选项,但也找不到在那里加载字体的选项。