From 06fec04c72a5f36040aebba0f233399235dc872c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 30 Mar 2017 08:52:35 +0100 Subject: [PATCH] Allow changing of title --- md_pdf/build/__init__.py | 2 +- md_pdf/build/pdf.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/md_pdf/build/__init__.py b/md_pdf/build/__init__.py index 5a5823f..11c8fb8 100644 --- a/md_pdf/build/__init__.py +++ b/md_pdf/build/__init__.py @@ -13,4 +13,4 @@ def build(config): output_html(doc, os.path.abspath(config.output_dir)) if 'pdf' in config.output_formats: render_cover() - export_pdf(doc, os.path.abspath(config.output_dir)) + export_pdf(doc, config) diff --git a/md_pdf/build/pdf.py b/md_pdf/build/pdf.py index 908f4c3..503923e 100644 --- a/md_pdf/build/pdf.py +++ b/md_pdf/build/pdf.py @@ -1,12 +1,12 @@ import pdfkit -from md_pdf.consts import PROJECT_DIR +from md_pdf.consts import ASSET_DIR from md_pdf.build.cover import OUTPUT_COVER_FILE import os -STYLE_FILE = os.path.join(PROJECT_DIR, 'assets', 'style.css') -HEADER_FILE = os.path.join(PROJECT_DIR, 'assets', 'header.html') -FOOTER_FILE = os.path.join(PROJECT_DIR, 'assets', 'footer.html') +STYLE_FILE = os.path.join(ASSET_DIR, 'style.css') +HEADER_FILE = os.path.join(ASSET_DIR, 'header.html') +FOOTER_FILE = os.path.join(ASSET_DIR, 'footer.html') PDF_OPTIONS = { "quiet": "", "no-pdf-compression": "", @@ -21,17 +21,17 @@ PDF_OPTIONS = { "footer-spacing": 5, "header-spacing": 5, - "title": "Title thing", "replace": [ ] } -def export_pdf(content, out_dir): +def export_pdf(content, config): + PDF_OPTIONS['title'] = getattr(config, 'title', 'output') return pdfkit.from_string( content, - os.path.join(out_dir, 'output.pdf'), + os.path.join(os.path.abspath(config.output_dir), 'output.pdf'), options=PDF_OPTIONS, css=STYLE_FILE, cover=OUTPUT_COVER_FILE