Django Easy PDF 无法显示包含静态文件 (css/images)



我试图使用django-easy-pdf将一些图像和CSS包含在我的PDF中,但是它们没有显示。

getFile '/static/open-iconic/font/css/open-iconic-bootstrap.css' '...\mysite\__dummy__' '...\mysite\__dummy__'
Traceback (most recent call last):
  File "...PythonPython36-32libsite-packagesxhtml2pdfcontext.py", line 828, in _getFileDeprecated
    nv = self.pathCallback(name, relative)
  File "...PythonPython36-32libsite-packageseasy_pdfrendering.py", line 35, in fetch_resources
    path = os.path.join(settings.STATIC_ROOT, uri.replace(settings.STATIC_URL, ""))
  File "...PythonPython36-32libntpath.py", line 75, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
line 0, msg: getFile %r %r %r, fragment: 

我的模板文件:

{% load static %}
<link href="{% static '/open-iconic/font/css/open-iconic-bootstrap.css' %}" rel="stylesheet">

我的文件夹结构:

mysite
- mysite
- app
    -static

在服务普通网页时,静态文件在PDF中工作。有任何建议吗?

在此线程中,django-easy-pdf可以使用WeasyPrint从本地file://或远程http/https URL呈现图像。这意味着您将编辑设置文件以与Django Site和谐相处。我修改了演示应用程序来说明这一点。克隆/拉动django-easy-pdf-demo-app 对于修改的应用程序。

最新更新