Duz*_*uzy 8 python pdf-to-html pdfkit
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
当我想使用这个方法时出现错误
\nTraceback (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\'?\nRun Code Online (Sandbox Code Playgroud)\n我该如何解决这个问题?
\n下面是完整的脚本
\nimport 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()\nRun Code Online (Sandbox Code Playgroud)\n
小智 -7
也许较新版本的 pdfkit 不支持 pdfkit.from_pdf。您可以尝试 pdfkit.from_file()
pdfkit.from_file(pdf_file, html_file)
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
17377 次 |
| 最近记录: |