Flask handling a PDF as its own page

前端 未结 5 1427
有刺的猬
有刺的猬 2020-12-14 08:52

For my personal website, I want to have a separate page just for my résumé, which is a PDF. I\'ve tried multiple ways, but I can\'t figure out how to get flask to handle a P

5条回答
  •  时光说笑
    2020-12-14 09:25

    You have two options. You can either render a template that uses a static PDF file or render a template that generates a PDF. I'd personally go with the first option.

    This SO question is dedicated to how to write an HTML page that returns a PDF. You can use this in your jinja2 template.

    Here's a quick and dirty way to get it done.

    
    

    Or, you can create a jinja2 template which sets all the headers required to return a PDF and then say,

    
    

    with a view function called static that returns the pdf.

    You can read more about the second option at this flask snippet

提交回复
热议问题