开发者

Image preview with Reportlab?

开发者 https://www.devze.com 2023-01-24 11:54 出处:网络
I\'m generating some pdf\'s with Reportlab and Django using a web interface. The pdf\'s are always going to be a single page. I\'d like to generate a png or jpg image of the generated page and return

I'm generating some pdf's with Reportlab and Django using a web interface. The pdf's are always going to be a single page. I'd like to generate a png or jpg image of the generated page and return that to the brow开发者_运维问答ser for the user to preview before saving the final pdf and delivering it to the end user. Is there anyway to do this?


This answer explains that you can use ghostscript to convert pdf to png. Depending of the requirements of your app (traffic, response time, nb of pdfs ...) it may or may not be a solution for you.

This is just an idea, but may be you can generate the preview image in parallel using PIL ImageDraw and get rid of the pdf-to-png conversion.

I hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号