![](/img/trans.png)
[英]How to convert webpage to pdf in python like the save as pdf option in print
[英]Python: Website has a Print option, with the option to download as PDF. How to do this with python automatically?
因此,例如,它是關於樂譜的鏈接: https ://thesession.org/tunes/12124/12124?print=true 這是一個特殊的打印頁面。 現在,由於至少 firefox 自動具有下載為 PDF 的選項,我想知道這是否可以用 python 自動完成。 如果可能的話,我可以將它嵌入到我的 GUI 中,並有一個用於顯示樂譜的應用程序。 有辦法嗎? 或者將 HTML 轉換為 PDF 的替代方法?
好的,我找到了答案,感謝 ScottC 他對另一個問題的引用:
用法
import pdfkit
pdfkit.from_url('http://google.com', 'out.pdf')
安裝
MacOS: brew install Caskroom/cask/wkhtmltopdf
Debian/Ubuntu: apt-get install wkhtmltopdf
Windows:choco 安裝 wkhtmltopdf
請參閱 MacOS/Ubuntu/其他操作系統的官方文檔: https ://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.