diff --git a/platypush/plugins/http/webpage/__init__.py b/platypush/plugins/http/webpage/__init__.py index ddf0f2c1..82bd1e8f 100644 --- a/platypush/plugins/http/webpage/__init__.py +++ b/platypush/plugins/http/webpage/__init__.py @@ -77,29 +77,37 @@ class HttpWebpagePlugin(Plugin): 'content': content, } - content = ''' - - - {title} - - - -

{title}

- {content} - - '''.format(title=title, content=content) - outfile = os.path.abspath(os.path.expanduser(outfile)) + content = '''

{title}

{content}
'''.\ + format(title=title, content=content) + + style = ''' + body { + font-size: 22px; + font-family: 'Merriweather', Georgia, 'Times New Roman', Times, serif; + } + ''' if outfile.lower().endswith('.pdf'): import weasyprint - weasyprint.HTML(string=content).write_pdf(outfile) + from weasyprint.fonts import FontConfiguration + + font_config = FontConfiguration() + css = [weasyprint.CSS('https://fonts.googleapis.com/css?family=Merriweather'), + weasyprint.CSS(string=style, font_config=font_config)] + + weasyprint.HTML(string=content).write_pdf(outfile, stylesheets=css) else: + content = ''' + + + {title} + + + {{content}} + + '''.format(title=title, style=style, content=content) + with open(outfile, 'w', encoding='utf-8') as f: f.write(content)