小编Duz*_*uzy的帖子

使用 python 和 pdfkit 将 PDF 转换为 HTML

Adobe在此网站上写了有关使用 pdfkit 将 pdf 转换为 html 的内容

\n

他们使用pdfkit.from_pdf(...)方法。

\n
\n

此脚本使用 \xe2\x80\x98pdfkit\xe2\x80\x99 库将 PDF 文件转换为 HTML。要使用此脚本,您需要安装 \xe2\x80\x98pdfkit\xe2\x80\x99 库...

\n
\n

当我想使用这个方法时出现错误

\n
Traceback (most recent call last):\n  File "C:\\TestPdfToHtml\\script.py", line 7, in <module>\n    html_file = pdfkit.from_pdf(pdf_file, "my_html_file.html")\n                ^^^^^^^^^^^^^^^\nAttributeError: module \'pdfkit\' has no attribute \'from_pdf\'. Did you mean: \'from_url\'?\n
Run Code Online (Sandbox Code Playgroud)\n

我该如何解决这个问题?

\n

下面是完整的脚本

\n
import pdfkit\n# Read the PDF file\npdf_file = open(\'test2.pdf\', \'rb\')\n# Convert the PDF to HTML\nhtml_file = pdfkit.from_pdf(pdf_file, "my_html_file.html")\n# Close the PDF file\npdf_file.close()\n
Run Code Online (Sandbox Code Playgroud)\n

python pdf-to-html pdfkit

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

标签 统计

pdf-to-html ×1

pdfkit ×1

python ×1