Flask Pdfkit - Невозможно добавить пользовательский шрифт - PullRequest
0 голосов
/ 21 апреля 2020

Я пытаюсь включить свой собственный шрифт, но получаю следующую ошибку, указывающую, что шрифт не найден. Однако я могу подтвердить, что правильно указываю на каталог шрифтов.

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 и просмотрел опции, но не смог найти вариант для загрузки там шрифта.

...