{"id":2308,"date":"2022-07-16T14:17:57","date_gmt":"2022-07-16T09:17:57","guid":{"rendered":"https:\/\/www.edopedia.com\/blog\/?p=2308"},"modified":"2022-07-16T14:24:51","modified_gmt":"2022-07-16T09:24:51","slug":"create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit","status":"publish","type":"post","link":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/","title":{"rendered":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit"},"content":{"rendered":"\n<p>In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the <code>pdfkit<\/code> library to create the PDF document with ease.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">pip install flask<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">pip install pdfkit<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">code.py<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">from flask import Flask\nfrom flask import render_template\nfrom flask import make_response\nimport pdfkit\n\napp = Flask(__name__)\n\n\n@app.route(&quot;\/&quot;)\ndef index():\n    name = &quot;SIR JOHN WILLIAMSON LATHAM&quot;\n    html = render_template(\n        &quot;certificate.html&quot;,\n        name=name)\n    pdf = pdfkit.from_string(html, False)\n    response = make_response(pdf)\n    response.headers[&quot;Content-Type&quot;] = &quot;application\/pdf&quot;\n    response.headers[&quot;Content-Disposition&quot;] = &quot;inline; filename=output.pdf&quot;\n    return response\n\n\nif __name__ == &quot;__main__&quot;:\n    app.run(debug=True)<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">templates\/certificate.html<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;h1&gt;Hello my name is\n{{name}}\n&lt;\/h1&gt;<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the pdfkit library to create the PDF document with ease. code.py templates\/certificate.html<\/p>\n","protected":false},"author":1,"featured_media":2310,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[],"class_list":["post-2308","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/\" \/>\n<meta property=\"og:site_name\" content=\"Edopedia\" \/>\n<meta property=\"article:author\" content=\"trulyfurqan\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-16T09:17:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-16T09:24:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"880\" \/>\n\t<meta property=\"og:image:height\" content=\"495\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Furqan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Furqan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit","description":"In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/","og_locale":"en_US","og_type":"article","og_title":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit","og_description":"In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the","og_url":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/","og_site_name":"Edopedia","article_author":"trulyfurqan","article_published_time":"2022-07-16T09:17:57+00:00","article_modified_time":"2022-07-16T09:24:51+00:00","og_image":[{"width":880,"height":495,"url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg","type":"image\/jpeg"}],"author":"Furqan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Furqan","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#article","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/"},"author":{"name":"Furqan","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339"},"headline":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit","datePublished":"2022-07-16T09:17:57+00:00","dateModified":"2022-07-16T09:24:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/"},"wordCount":52,"commentCount":0,"publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/","url":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/","name":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#primaryimage"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg","datePublished":"2022-07-16T09:17:57+00:00","dateModified":"2022-07-16T09:24:51+00:00","description":"In this tutorial, you will get the full source code of the Python 3 Flask project to create a PDF document using a dynamic HTML5 template. We will use the","breadcrumb":{"@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#primaryimage","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/Create-PDF-in-Python3-Flask-pdfkit.jpg","width":880,"height":495,"caption":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit"},{"@type":"BreadcrumbList","@id":"https:\/\/www.edopedia.com\/blog\/create-pdf-using-dynamic-html5-template-in-python3-flask-pdfkit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edopedia.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Create PDF Using Dynamic HTML5 Template in Python 3 Flask pdfkit"}]},{"@type":"WebSite","@id":"https:\/\/www.edopedia.com\/blog\/#website","url":"https:\/\/www.edopedia.com\/blog\/","name":"Edopedia","description":"Coding\/Programming Blog","publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edopedia.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.edopedia.com\/blog\/#organization","name":"Edopedia","url":"https:\/\/www.edopedia.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","width":400,"height":100,"caption":"Edopedia"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339","name":"Furqan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","caption":"Furqan"},"description":"Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.","sameAs":["http:\/\/www.edopedia.com\/blog\/","trulyfurqan"],"url":"https:\/\/www.edopedia.com\/blog\/author\/furqan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/comments?post=2308"}],"version-history":[{"count":0,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2308\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media\/2310"}],"wp:attachment":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media?parent=2308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/categories?post=2308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/tags?post=2308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}