1 pip install pdf2image
2 poppler
pdf2image是包裝器,poppler是轉換過程真正需要的。
用curl下載:http://blog.alivate.com.au/wp-content/uploads/2018/10/poppler-0.68.0_x86.7z,解壓後,把bin目錄添加到PATH
環境變量裏。
3 代碼
from pdf2image import convert_from_path
convert_from_path('1.pdf', 300, "output", fmt="JPEG", output_file="essay", thread_count=1)
4
上述pdf文件重命名爲1.pdf,運行上述代碼,結果如下: