Weasyprint 显示 - “Fontconfig 错误:无法加载默认配置文件”

问题描述

要使用 weasyprint 安装的 gkt 使用 msys2 安装程序和环境变量中的给定路径创建 pdf,但是 “Fontconfig 错误:无法加载配置文件 弹出。

# html to pdf creator libraries
from jinja2 import Environment,FileSystemloader
from weasyprint import HTML
#from fpdf import FPDF

#other libraries
import base64
from tempfile import NamedTemporaryFile


def set_dll_search_path():
   if os.name != "nt" or not hasattr(os,"add_dll_directory"):
       return
   for p in os.environ.get("PATH","").split(os.pathsep):
       try:
           os.add_dll_directory(p)
       except OSError:
           pass

set_dll_search_path()

................ code to get results ........................


....... loading results to pdf ..................

env = Environment(loader=FileSystemloader('.'))
template = env.get_template("myreport.html")

template_vars = {"title" : "Dashboard","table": df.sort_values(by = ['Bytes'],ascending=False).head(10).to_html(index= False),'size_table' : size_summary.sort_values(by = ['Bytes'],ascending=False).to_html(index= False),'time_table' : time_summary.sort_values(by = ['Bytes'],'count_table' : result['count'],'size' : result['size'],'basename' : basename
                }

html_out = template.render(template_vars)

HTML(string=html_out,base_url='.').write_pdf("Table.pdf",stylesheets=["style.css"])

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)