python根据模板生成pdf文件,python生成pdf报告图片文字

  python根据模板生成pdf文件,python生成pdf报告图片文字

  1.安装pdfkit

  pip安装pdf包

  2.安装wkhtmltopdf

  下载地址:https://wkhtmltopdf.org/downloads.html

  根据您自己的版本下载安装包

  安装rpm-ivhwkhtmltox-0 . 12 . 5-1 . centos 6 . x86 _ 64 . rpm-nodeps

  3.安装中文字体。

  如果不安装中文字体,pdf生成会出现乱码。

  yum install-y font config mkfont scale

  通过sftp工具直接将windows上的字体上传到linux服务器。

  Windows字体存储目录C:\Windows\Fonts

  Linux字体存储目录/usr/share/fonts/

  只需上传一个或多个到linux。

   mkfontscale

   mkfontdir

  光纤通道缓存

  使用命令fc-list :lang=zh验证您上传的字体徽标已成功安装。

  生成pdf文件(template.html是我的模板文件,模板文件要设置成utf-8格式)

  With (template.html , r ,encoding= utf-8 )as f:content=f . read()content=content . replace( { replace tag } ,str( replace result ))pdf kit . from _ string(content, test.pdf)

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: