def _create_pdf_libreoffice(self):
output_image = BytesIO()
self._map_image.save(output_image, 'PNG')
render = Renderer(media_path='.')
# TODO: use the configuration to select the template
# TODO: use the configuration to select the name of the key in the template
result = render.render('template.odt', my_map=output_image)
with NamedTemporaryFile(
mode='wb+',
prefix='geo-pyprint_',
delete=True
) as generated_odt:
generated_odt.write(result)
generated_odt.flush()
output_name = generated_odt.name + '.pdf'
cmd = [
'unoconv',
'-f',
'pdf',
'-o',
output_name,
generated_odt.name
]
subprocess.call(cmd, timeout=None)
return output_name
评论列表
文章目录