小编del*_*rio的帖子

Weasyprint 在调用 write_pdf 时获得未定义的属性:“AttributeError:‘PosixPath’对象没有属性‘read_text’”

我正在 ubuntu 18.04 上运行 weasyprint 项目,并尝试创建 aa pdf。

当我尝试设置页脚图像时,问题就开始了。我正在 python 3.6.7 上运行

这是我调用 weasyprint 的代码:

import sys
import os
from weasyprint import HTML, CSS

htmlFile = sys.argv[1]
pdfFile = sys.argv[2]

html = HTML(filename=htmlFile)

css = CSS(string='@page { @bottom-center { width: 125%; margin-top: 10px; content: " "; background-image: url(file://' + os.getcwd() + '/pdf/footer.png); background-repeat: no-repeat; background-position: right;  background-size: 100%; } }')

html.write_pdf(pdfFile, stylesheets=[css])
Run Code Online (Sandbox Code Playgroud)

但后来我收到以下错误:

Error: Command failed: python3 /node_modules/my-project/python/run.py /node_modules/my-project/pdf/catalog_01e299a3-1fca-482b-a512-e1bea832559f.html /node_modules/my-project/pdf/catalog_01e299a3-1fca-482b-a512-e1bea832559f.pdf
Traceback (most recent call last):
File "/node_modules/my-project/python/run.py", line 3, in …
Run Code Online (Sandbox Code Playgroud)

python cairo weasyprint ubuntu-18.04

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

cairo ×1

python ×1

ubuntu-18.04 ×1

weasyprint ×1