mapprint.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:geo-pyprint 作者: ioda-net 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号