From e89c48ffdf6a996ed65aabbeeb2c1f17e68fb8f1 Mon Sep 17 00:00:00 2001 From: Ed Ward Date: Fri, 2 Aug 2019 11:06:35 +0200 Subject: [PATCH] Added metadata to the PDF --- build.py | 8 +++++--- pdf-template.html | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index 76eee46f..e9f4f279 100755 --- a/build.py +++ b/build.py @@ -27,6 +27,7 @@ global_onepage_template = 'onepage-template.html' global_pdf_template = 'pdf-template.html' global_master_doc = 'master-doc.txt' from datetime import datetime +global_today_iso = datetime.today().strftime('%Y-%m-%dT%H%M%S') global_today = datetime.today().strftime('%Y-%m-%d') # This matches all *non* letter/number, ' ', '.', '-', and '_' chars @@ -685,6 +686,7 @@ if not nopdf: pdfpage = pdfpage.replace('{% tree %}', opsidebar) # create the TOC pdfpage = pdfpage.replace('{{ content }}', '') # cleans up the last spaceholder pdfpage = pdfpage.replace('{{ today }}', global_today) + pdfpage = pdfpage.replace('{{ today_iso }}', global_today_iso) pdfpage = pdfpage.replace('src="/images/', 'src="images/') # makes images links relative pdfpage = pdfpage.replace('url(\'/images/', 'url(\'images/') # CSS images links relative # Write it to disk (optional, can be removed) @@ -694,10 +696,10 @@ if not nopdf: # Generating the actual PDF with weasyprint (https://weasyprint.org/) from weasyprint import HTML - #from weasyprint.fonts import FontConfiguration - #html_font_config = FontConfiguration() + from weasyprint.fonts import FontConfiguration + html_font_config = FontConfiguration() doc = HTML(string = pdfpage, base_url = global_site_dir) - doc.write_pdf(global_site_dir + 'manual.pdf')#, font_config = html_font_config) + doc.write_pdf(global_site_dir + 'manual.pdf', font_config = html_font_config) if not quiet: print('Processed ' + str(fileCount) + ' files.') diff --git a/pdf-template.html b/pdf-template.html index 5ef5ffc7..b90d28d5 100644 --- a/pdf-template.html +++ b/pdf-template.html @@ -3,8 +3,13 @@ - {{page.page_title}} + + + + + +